Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #12112
| From | Mike Duffy <Use_guestbook_page@website.in.sig> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Submitting a Form that has Control Events |
| Date | 2012-02-23 23:41 +0000 |
| Organization | Your Company |
| Message-ID | <XnsA002BE1BCEAAEinvalidcom@94.75.214.39> (permalink) |
| References | <9ghbk7hh8t3jbka7kmepejfnqng4vbjqgo@4ax.com> <XnsA002502F4CF5Finvalidcom@94.75.214.39> <621dk7dl90v2t97pca84jdquncbu3sk07u@4ax.com> |
Gene Wirchenko <genew@ocis.net> wrote in
news:621dk7dl90v2t97pca84jdquncbu3sk07u@4ax.com:
>
> For now, I am using the button. Why does the event not fire
> reliably?
If it is the "submit" element, perhaps the form submission is occuring
before the onClick event can be executed. I had a similar problem (see my
guest page on the website in the sig). I fixed it by programatically
disabling the submit button when the page is loaded.
The disabled form and disabled button within are defined with:
<form name="contact" id="mail_form" method="post" action="">
<... Other form elements ...>
<input name="sub_mess" id="Submit_Button" type="submit" value="(Button
Disabled)" class="button">
<... Other form elements ...>
</form>
Following line is in the body onLoad handler:
document.getElementById('Submit_Button').disabled = true;
I use the following function enable the send button. In my case, I just
want to pop up a message if the user hit return; anything else enables
the send button
function armSendButton(arg)
{
if (arg == 13) {alert('Use the button !!!'); return false;};
// Presumably, your form element handlers will ensure that
// all form values are okay. Otherwise return "false" here.
// Update button text so user knows it will work now.
document.forms.contact.sub_mess.value="Send the Message";
// (Change the ... to your own values.)
// You might not be using the recipient nor redirect
document.forms.contact.recipient.value = "...";
document.forms.contact.redirect.value = "....";
document.getElementById("mail_form").action = "...";
// Enable the submit button
document.getElementById("Submit_Button").disabled = false;
return true;
}
>
> Oh, my. Something else to worry about. It seems it never ends.
I made a mistake. You do not need onClick handlers for text fields, but
you should have onKeypress for all non-text fields to handle user hitting
Escape, Enter, or Tab. These handlers can just check for Enter (do a form
submit), Escape (do a form reset), or a Tab (do nothing; your onBlur
event should fire anyways.)
--
http://pages.videotron.ca/duffym/index.htm
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Submitting a Form that has Control Events Gene Wirchenko <genew@ocis.net> - 2012-02-22 21:03 -0800
Re: Submitting a Form that has Control Events Mike Duffy <Use_guestbook_page@website.in.sig> - 2012-02-23 12:52 +0000
Re: Submitting a Form that has Control Events Gene Wirchenko <genew@ocis.net> - 2012-02-23 10:36 -0800
Re: Submitting a Form that has Control Events Mike Duffy <Use_guestbook_page@website.in.sig> - 2012-02-23 23:41 +0000
Re: Submitting a Form that has Control Events Gene Wirchenko <genew@ocis.net> - 2012-02-23 16:48 -0800
Re: Submitting a Form that has Control Events Gene Wirchenko <genew@ocis.net> - 2012-02-23 17:00 -0800
Re: Submitting a Form that has Control Events Mike Duffy <Use_guestbook_page@website.in.sig> - 2012-02-24 02:22 +0000
Re: Submitting a Form that has Control Events Gene Wirchenko <genew@ocis.net> - 2012-02-23 18:35 -0800
Re: Submitting a Form that has Control Events Mike Duffy <Use_guestbook_page@website.in.sig> - 2012-02-24 05:10 +0000
Re: Submitting a Form that has Control Events Gene Wirchenko <genew@ocis.net> - 2012-02-24 09:43 -0800
Re: Submitting a Form that has Control Events Mike Duffy <Use_guestbook_page@website.in.sig> - 2012-02-24 02:22 +0000
csiph-web