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>
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>