473,748 Members | 7,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Submitting A Form

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.d isabled=true;
this.value = 'Submitting...' ; this.form.submi t();">

But when I try to make a function it doesn't work:

<script language="JavaS cript">
function DisableButton(b ) {
b.disabled = true;
b.value = 'Submitting...' ;
b.form.submit() ;
}
</script>

<input type="button" value="Submit" name="submit"
onClick="Disabl eButton(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?

Nov 2 '06 #1
4 2799
because b=to the button not to the form the riht syntax should be:

window.document .FormName.submi t();
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?
Nov 2 '06 #2
Super Steve wrote:
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.d isabled=true;
this.value = 'Submitting...' ; this.form.submi t();">

But when I try to make a function it doesn't work:

<script language="JavaS cript">
function DisableButton(b ) {
b.disabled = true;
b.value = 'Submitting...' ;
b.form.submit() ;
}
</script>

<input type="button" value="Submit" name="submit"
onClick="Disabl eButton(this);" >

When I try this the button text is changed and the button is
disabled, but the form doesn't submit. ...
<snip>

<URL: http://jibbering.com/faq/faq_notes/f....html#faComMis >

Richard.
Nov 2 '06 #3
Thanks for your reply. Initially I thought the same as you, but then I
read that every form element also had a "form" property that points to
the form that the element is an item of.

"All form element objects also have the form property, which returns
the Form object in which the element is contained. This can be useful
in cases where you have a generic routine that checks the validity of
data in a form. For example, when the user clicks a submit button, we
can pass the Form object referenced by the form property to our data
checker which can use it to loop through each element on the form in
turn, checking that data in the element is valid. This is handy if you
have more than one form defined on the page or where you have a generic
data checker that you cut and paste to different pages - this way you
don't need to know the form's name in advance."

So I don't know why b.form.submit.( ) doesn't work when b is pointing to
the button element within the form.
So*****@gmail.c om wrote:
because b=to the button not to the form the riht syntax should be:

window.document .FormName.submi t();
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?
Nov 2 '06 #4
Awsome, Richard!

Well that's a trap for your players. I've always named my submit
buttons "submit" in the past, but then I've never tried to access them
with JavaScript before. Changing the name to "submitform " now makes
everything work.

Many thanks for your help!
Richard Cornford wrote:
<URL: http://jibbering.com/faq/faq_notes/f....html#faComMis >

Richard.
Nov 2 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3793
by: Display Name | last post by:
the customer I'm developing a site for uses a canned form-parsing page that allows her to have an email subscription opt-in page add emails to a list she can manage using a link that you point your HTML form to. the actual form-parsing page resides on a server that's uneditable to me since it sits on an inaccessible server. my problem is more irritating than anything; everything double-submits.. when you submit the form, I've forced a...
2
2220
by: Greg T | last post by:
Hi, I have a rather long form that I don't want people submitting unless they are absolutely sure they are ready. I figured the easiest way to prevent an accidental form submission by way of hitting of the enter key was to simply not have a submit button, instead going for a regular anchor which calls a javascript confirmation box and then submits the form.
5
1911
by: Don | last post by:
I have a need to submit a form, but don't need the user to click on a button. How do I do this? Is there some way, using JavaScript, to setup a <form> tag to do this? Thanks, Don ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= East/West-Coast Server Farms - Total Privacy via Encryption =---
1
1668
by: Richard Dixson | last post by:
I have code that calls document.myFormName.submit() to submit a form automatically via JavaScript. This works just fine. However, if there is a button (or other form field element) on the form named "submit", this results in a JS error saying that "the object doesn't support this property or method". I think what is happening in this case is that document.myFormName.submit() is then trying to call a method on the form field element...
1
1528
by: Hello | last post by:
Scenario: A page creates a pop up and that pop up submits a form. Is there a way to detect whether the submitting was successful or not, so true/false could be passed to the parent window?
3
1903
by: kgbalaji1980 | last post by:
Hi all, i want the jscript coding for more than one form in one page and submitting the same . ie one parent form and one append button when we click that button one child form will display and so on. we have to submitting for the same regards Balaji
18
13142
by: NavinM | last post by:
I have a couple of forms that are misbehaving in FireFox, but work fine in IE. when i do submit( with submit button) a javascript function validates all of the fields entered, and stops the submission if there is an error. Sample (obviously not working code): <html> <head> <script type="text/javascript"> function Submit() {
1
3237
by: dittu | last post by:
How to close the popup window when submitting the form? I have a sample.jsp. In that page one button is there. when button pressed, open popup window contains one "text box" and one " submit button". when "submit" button pressed, call the "servlet" in this popup window and then close the "popup" window. <SCRIPT LANGUAGE="JavaScript"> <!-- Begin var X = 200; // change the # at the left for a fixed X co-ordinate to accommodate...
6
4975
by: phpnewbie26 | last post by:
This has been confusing me for a while. I don't understand why it isn't working. In my original coding, I have an action called submitted.php and this is what is looks like: <?php $data=fopen("/home/vchan/ts2/writing.txt","r+"); while(!feof($data)){ $data2=fgets($data); $tmp=explode(",",$data2); $project=$tmp; $code=$tmp;
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9544
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8243
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.