Menu
Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Javascript
Submitting A Form
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Super Steve" data-source="post: 4936242"><p>I'm trying to write a little script that disables the submit button on</p><p>a form, changes the text of the button, and then submits the form.</p><p></p><p>Can anyone tell me why this works ok:</p><p></p><p><input type="button" value="Submit" onClick="this.disabled=true;</p><p>this.value = 'Submitting...'; this.form.submit();"></p><p></p><p>But when I try to make a function it doesn't work:</p><p></p><p><script language="JavaScript"></p><p>function DisableButton(b) {</p><p>b.disabled = true;</p><p>b.value = 'Submitting...';</p><p>b.form.submit();</p><p>}</p><p></script></p><p></p><p><input type="button" value="Submit" name="submit"</p><p>onClick="DisableButton(this);"></p><p></p><p>When I try this the button text is changed and the button is disabled,</p><p>but the form doesn't submit. In IE I get an error that points to the</p><p>line that says:</p><p></p><p>b.form.submit();</p><p></p><p>and the error:</p><p></p><p>Object doesn't support this property or method</p><p></p><p>What's the difference between doing this code directly in the onClick</p><p>event and doing it in a function?</p></blockquote><p></p>
[QUOTE="Super Steve, post: 4936242"] I'm trying to write a little script that disables the submit button on a form, changes the text of the button, and then submits the form. Can anyone tell me why this works ok: <input type="button" value="Submit" onClick="this.disabled=true; this.value = 'Submitting...'; this.form.submit();"> But when I try to make a function it doesn't work: <script language="JavaScript"> function DisableButton(b) { b.disabled = true; b.value = 'Submitting...'; b.form.submit(); } </script> <input type="button" value="Submit" name="submit" onClick="DisableButton(this);"> When I try this the button text is changed and the button is disabled, but the form doesn't submit. In IE I get an error that points to the line that says: b.form.submit(); and the error: Object doesn't support this property or method What's the difference between doing this code directly in the onClick event and doing it in a function? [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Javascript
Submitting A Form
Top