Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 3.00 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-22-2008, 01:04 AM   PM User | #1
o0O0o.o0O0o
Senior Coder

 
o0O0o.o0O0o's Avatar
 
Join Date: Jan 2008
Location: C:\Windows\System32
Posts: 1,018
Thanks: 19
Thanked 9 Times in 9 Posts
o0O0o.o0O0o is infamous around these parts
document.getElementById(formID).submit() will work or not

i have the form id and i want to submit the form

Code:
document.getElementById(formID).submit();
Is this the correct way or not
__________________
Please de-reputate me
© 0o0o0o0

Its better to rule in Hell then to serve in Heaven
o0O0o.o0O0o is offline   Reply With Quote
Old 05-22-2008, 01:18 AM   PM User | #2
binaryWeapon
Regular Coder

 
Join Date: Sep 2007
Location: AZ, USA
Posts: 685
Thanks: 6
Thanked 46 Times in 46 Posts
binaryWeapon is on a distinguished road
Yes, I believe so. Try testing it, or google it. First link from google search: http://www.javascript-coder.com/java...m-submit.phtml
binaryWeapon is offline   Reply With Quote
Old 05-22-2008, 01:30 AM   PM User | #3
o0O0o.o0O0o
Senior Coder

 
o0O0o.o0O0o's Avatar
 
Join Date: Jan 2008
Location: C:\Windows\System32
Posts: 1,018
Thanks: 19
Thanked 9 Times in 9 Posts
o0O0o.o0O0o is infamous around these parts
Its not working ,

I think in that link was using form name and i want to use formID . thats why its not working
__________________
Please de-reputate me
© 0o0o0o0

Its better to rule in Hell then to serve in Heaven
o0O0o.o0O0o is offline   Reply With Quote
Old 05-22-2008, 02:47 AM   PM User | #4
ghostz00
Regular Coder

 
ghostz00's Avatar
 
Join Date: Aug 2006
Posts: 128
Thanks: 11
Thanked 2 Times in 2 Posts
ghostz00 is an unknown quantity at this point
Make sure that the formid is in quotes.

Code:
document.getElementById("formID").submit();
__________________
Greg
ghostz00 is offline   Reply With Quote
Old 05-22-2008, 05:03 AM   PM User | #5
binaryWeapon
Regular Coder

 
Join Date: Sep 2007
Location: AZ, USA
Posts: 685
Thanks: 6
Thanked 46 Times in 46 Posts
binaryWeapon is on a distinguished road
Sorry I couldn't get right back to you; had to rush out and do something as soon as I sat down to answer.

Quote:
I think in that link was using form name and i want to use formID . thats why its not working
That's not it. They were using a different (and more traditional) way of traversing the DOM, but it still selects the same element. It's like the different between going somewhere in a helicopter (getElementByID) and driving there on surface streets (document.formname).

Try
Code:
var myform=document.getElementById(formID);
myform.submit();
One last thing to note is that you are specifying the id of your form correctly; sometimes I get confused and accidentally specify it as the name.

BTW, is that all the code you have so far? If there's a specific situation you're using it in, there could be other elements effecting it.
binaryWeapon is offline   Reply With Quote
Old 05-22-2008, 05:44 AM   PM User | #6
o0O0o.o0O0o
Senior Coder

 
o0O0o.o0O0o's Avatar
 
Join Date: Jan 2008
Location: C:\Windows\System32
Posts: 1,018
Thanks: 19
Thanked 9 Times in 9 Posts
o0O0o.o0O0o is infamous around these parts
I am using one form with multi buttons , i am using code below



Code:
function submitForm2(formID , action)

{

document.getElementById(formID).action = action;

document.getElementById(formID).submit();

}

<
Code:
form id = 'form_1' action="" method=post>

<input class="left" type="button" name="submit" value="Show" 
    onClick="submitForm2('form_1','test.php')"> 

<input class="left" type="button" name="submit" value="Show" 
    onClick="submitForm2('form_1','test2.php')">
__________________
Please de-reputate me
© 0o0o0o0

Its better to rule in Hell then to serve in Heaven
o0O0o.o0O0o is offline   Reply With Quote
Old 05-22-2008, 12:51 PM   PM User | #7
A1ien51
Senior Coder

 
A1ien51's Avatar
 
Join Date: Jun 2002
Location: Between DC and Baltimore In a Cave
Posts: 2,717
Thanks: 1
Thanked 94 Times in 88 Posts
A1ien51 will become famous soon enough
You can not have the buttons named submit and use submit(). The buttons override the method. Rename the buttons to something else and it will work.

Eric
__________________
Tech Author [Ajax In Action, JavaScript: Visual Blueprint]
A1ien51 is offline   Reply With Quote
Old 05-22-2008, 12:55 PM   PM User | #8
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
Make sure you have no element with the name or id = "submit". IE woun't like that, as it will be confused between what it considers an object referenced by the name/id submit and the method submit()
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:46 AM.


Advertisement
Log in to turn off these ads.