HighDots Forums  

set focus() on textfield in IE problems

Javascript JavaScript language (comp.lang.javascript)


Discuss set focus() on textfield in IE problems in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Marco Alting
 
Posts: n/a

Default set focus() on textfield in IE problems - 09-24-2003 , 08:41 AM






Hi

I've read some solutions to my problem on the web, but I'm not able yet to
implent it in my function, can anyone help me out here? I'm trying to get
back the focus on a textfield after closing an alert box, but the focus
jumps to the next textfield. Here's the function:

function ValueChanged(obj, variation){
var ChangedValue = document.getElementById(obj);
var Budget = document.getElementById("Budget" + variation);
var Committed =document.BudgetItem.getElementById("committed" + variation);
var Actual = document.getElementById("actual" + variation);
var Accrual = document.getElementById("accrual" + variation);
var ChangedHidden = document.getElementById("changedValues" + variation);

ActualPlusAccrual = parseFloat(Actual.value) + parseFloat(Accrual.value);

ChangedValue.style.backgroundColor='#ffcc00';
ChangedHidden.value = true;
if(Budget.value - Committed.value < 0){
alert("Committed value can not be greater than the Budget");
Committed.focus();
Committed.select();
return false;
}
if(Budget.value - Actual.value < 0){
alert("Actual value can not be greater than the Budget");
Actual.focus();
Actual.select();
return false;
}
if(Budget.value - Accrual.value <0){
alert("Accrual value can not be greater than the Budget");
Accrual.focus();
Accrual.select();
return false;
}
if(Committed.value - ActualPlusAccrual < 0){
alert("Committed value can not be less than Actual + Accrual");
Committed.focus();
Committed.select();
return false;
}
if(Budget.value - ActualPlusAccrual < 0){
alert("Actual + Accrual can not be greater than the Budget");
Actual.focus();
Actual.select();
return false;
}
}
</script>



Reply With Quote
  #2  
Old   
HikksNotAtHome
 
Posts: n/a

Default Re: set focus() on textfield in IE problems - 09-25-2003 , 08:53 PM






In article <Fahcb.131530$rh.11348016 (AT) amsnews03 (DOT) chello.com>, "Marco Alting"
<marco (AT) hotmail (DOT) com> writes:

Quote:
var ChangedValue = document.getElementById(obj);
var Budget = document.getElementById("Budget" + variation);
var Committed =document.BudgetItem.getElementById("committed" + variation);
Why the above line isn't throwing errors is erroneous and suspicious.

Quote:
var Actual = document.getElementById("actual" + variation);
var Accrual = document.getElementById("accrual" + variation);
var ChangedHidden = document.getElementById("changedValues" + variation);
Why are you using getElementById to reference a form? use document.forms
notation and set focus at will.
--
Randy


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.