473,385 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Submiting a form using javascript

Hi,

First let me point out I have googled this and also must have done
this operation a dozen times (altho a few years ago) but for some
reason I cant get a form to submit using javascript .. Ive tried both
FF and IE. All the pages that I look at all say the same way which is
the way Im sure Ive done it before:
My code is:

(javascript function)

function DeleteImages (oForm) {
alert('submitting form') // this works ...
oForm.submit() // this doesnt!!
}

(html button)

<input type="button" name="submit" value="Delete Selected"
onclick="DeleteImages(this.form);" />
Maybe just a sanity check is needed but I cant see what the problem
is. Where am I going wrong? I know that the function is being called
because the alert message is executing but the form isnt submitting.

Cheers

Burnsy
Feb 13 '08 #1
6 1702
On Feb 13, 10:15*pm, bizt <bissa...@yahoo.co.ukwrote:
First let me point out I have googled this and also must have done
this operation a dozen times (altho a few years ago) but for some
reason I cant get a form to submit using javascript .. Ive tried both
FF and IE. All the pages that I look at all say the same way which is
the way Im sure Ive done it before:
[...]
<input type="button" name="submit" value="Delete Selected"
onclick="DeleteImages(this.form);" />
Browsers make named controls available as properties of the DOM form
object. Giving any control a name of 'submit' shadows the form's
submit method, so form.submit() is equivalent to
form.elements['submit']().

There is rarely any need to name a submit button, remove the name (or
change it to something other than 'submit') and life will return to
normal...
--
Rob
Feb 13 '08 #2
RobG meinte:
There is rarely any need to name a submit button
There is. Frequently. When your server-side script wants to know,
whether you hit "cancel" or "delete" or "save"...

Gregor
--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Feb 13 '08 #3

"Gregor Kofler" <us****@gregorkofler.atwrote in message
news:KE**************@nntpserver.swip.net...
RobG meinte:
>There is rarely any need to name a submit button

There is. Frequently. When your server-side script wants to know, whether
you hit "cancel" or "delete" or "save"...
So? Can't you name it 'delete', 'cancel' and 'save'?

http://medjimurje.net
Feb 14 '08 #4
On Feb 14, 3:13 am, Gregor Kofler <use...@gregorkofler.atwrote:
RobG meinte:
There is rarely any need to name a submit button

There is. Frequently. When your server-side script wants to know,
whether you hit "cancel" or "delete" or "save"...
I guess you mean where a form has multiple submit buttons to indicate
which of a number of actions to take when the form is submitted - the
name can be used to determine which button was used to submit it.

That's certainly one case where naming the button is useful, athough
the same functionality can be provided using a single submit button
and say checkboxes or radio buttons to indicate the action to take.
--
Rob
Feb 14 '08 #5
RobG meinte:
On Feb 14, 3:13 am, Gregor Kofler <use...@gregorkofler.atwrote:
>RobG meinte:
>>There is rarely any need to name a submit button
There is. Frequently. When your server-side script wants to know,
whether you hit "cancel" or "delete" or "save"...

I guess you mean where a form has multiple submit buttons to indicate
which of a number of actions to take when the form is submitted - the
name can be used to determine which button was used to submit it.

That's certainly one case where naming the button is useful, athough
the same functionality can be provided using a single submit button
and say checkboxes or radio buttons to indicate the action to take.
Agreed, but I wouldn't call that good usability.
"
I want to

[ ] cancel editing
[ ] save this record
[ ] delete this record

[ Go >]
"

When have you last seen such a form? (It makes sense for multiple
entries, though.)

Gregor
--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Feb 14 '08 #6
Zvonko Biskup meinte:
"Gregor Kofler" <us****@gregorkofler.atwrote in message
news:KE**************@nntpserver.swip.net...
>RobG meinte:
>>There is rarely any need to name a submit button
There is. Frequently. When your server-side script wants to know, whether
you hit "cancel" or "delete" or "save"...

So? Can't you name it 'delete', 'cancel' and 'save'?
Sure. But you *named* it.

Gregor
--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Feb 14 '08 #7

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

Similar topics

8
by: Bartosz Wegrzyn | last post by:
Please look at my code. I do validation of my form before I submit it. I want to be able to to press one form button without running validating script. I just want to go directly to my php...
1
by: Pat | last post by:
Here is how I have been submiting a form to a popup window, this works fine for all netscape versions and all IE versions previous to 6.0.2800.1106. Does anyone know a different way I can submit a...
2
by: Robert Diamond | last post by:
Hey guys (and girls ;)), I want to create some form data and submit it to the cgi script without having any (DOM) document loaded up. Is there a way in jscript to say... (probably something...
6
by: Abby Lee | last post by:
I have a for statement in my validation process I do a for loop becasue I don't know how many rows of items there are...I need to validate each item in each row. If I remove the...
5
by: midnight_use_only | last post by:
hi all, quick question, how do you submit a form to a parent window from a child popup window? i have the following and all online documentation *suggests* that it should work but it does NOT: ...
2
by: mohawk411 | last post by:
Hello, I am having a problem with developing my form, when i click submit in ie the form validates itself and is submitted but when I open the form in firefox it will not validate or submit the form,...
3
Ajm113
by: Ajm113 | last post by:
Ok for some reason after the update of Firefox it seems that my form keeps getting submitted when the user made a error on the form. I just want the page to reload so the user may try again. Because...
5
by: rodrigo21 | last post by:
I have a form that submits the form values to the same page (of the form). The database is feed from the same page that have the form in it. So the action attribute would look like this <form...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.