Focus()

crule

New member
Joined
Sep 25, 2010
Messages
1
Programming Experience
Beginner
I have looked all over - my solution (as I've found on many sites) does not work.
I have a javascript confirm box and based on what the user answers, I would like to change control focus....seems easy but nothing is working.
I first tried this:
if ((diffExtExc > 31 || diffExtExc < -31) && (diffExtCurr > 7 || diffExtCurr < -7))
{
var answer = confirm("Extract date is > 31 days from Execution Date and > 7 days from today. Do you want to continue?");
if (answer == true)
{
document.getElementById('ddlContractType').focus();
}
}

Then I tried putting the var answer variable higher and after all the If/Elses - to do one
more
if (answer == true) {
document.getElementById('ddlContractType').focus();
}

Didn't work - then I tried calling 2 functions on texchanged - and put the answer var outside of the function and did this:

function setFocus() {
var inp = document.getElementById('ddlContractType');
if (answer == true) {
alert("here: " + answer);
//document.getElementById('ddlContractType').focus();
inp.focus();
}

}

when I step throught the javascript code...it shows "answer" = true, but my ddlContractType control never gets the focus.

Does it have something to do with the confirm box?

Any help would be appreciated.
Thanks.
 
Back
Top