set focus() on textfield in IE problems

M

Marco Alting

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top