Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Give Focus to a Button After A Function Call....

Status
Not open for further replies.

phatening

Programmer
Aug 8, 2005
18
US
Hi All,

I appreciate your time guys. If you scroll down to the end of the page given below, you will see that the submit button is disabled. It is disabled from <body onload(...)>. If you check the checkbox above the submit button and click the button right afterwards, the button will appear enabled. I am trying to get the button to appear enabled just by checking the checkbox and without any extra actions. If you check my source code, then you can see that I do use focus(), but it doesn't work until u click somewhere on the page after checking the checkbox. Any suggestions? Thanks.. I appreciate any help!

The function with the focus() method is outlined in the source code with: //***** THE PITFALL ******
And the submit button and checkbox is in that last few lines of the soure code.

THE URL:
 
>you can see that I do use focus(), but it doesn't work until u click somewhere on the page after checking the checkbox

[1] Change the onchange(this.form) to onclick(this.form) will solve the problem.
[tt] <input type="checkbox" name="agreement" onclick="checkAgreement(this.form);"/>[/tt]

[2] If you further need the focus, then change the handler as well to add that focus().
[tt]
function checkAgreement(form) {
if (form.agreement.checked) {
form.submitButton.disabled=false;
form.submitButton.focus();
} else {
form.submitButton.disabled=true;
}
}
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top