[SOLVED] Why this does not work?

This is a discussion on "[SOLVED] Why this does not work?" within the JavaScript Forum section. This forum, and the thread "[SOLVED] Why this does not work? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 4th, 2008, 03:46
New Member
Join Date: Jan 2008
Location: My Home
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb [SOLVED] Why this does not work?

I am a javascript beginner and want to submit a php form by a usual button not submit button.
I wanted to do this by document.<formname>.submit() ,but this did not work and I get an error in javascript console that saied submit() is not a function.
I would be very grateful if someone can help me to achieve this problelm?
Reply With Quote

  #2 (permalink)  
Old Jan 4th, 2008, 04:15
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Re: Why this does not work?

Does this helps?Any reason you don't want to use the normal html submit button?
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)

Last edited by Monie; Jan 4th, 2008 at 04:20.
Reply With Quote
  #3 (permalink)  
Old Jan 4th, 2008, 04:51
New Member
Join Date: Jan 2008
Location: My Home
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Why this does not work?

Thanks Monie,
First, I have to use this method because I use AJAX to send some information to web server and authonticate via mysql. So I have to use another submission method than usual submit button.

Second, Again thanks for your links but they could not help me because I do all the things correct but the submit() does not trigger and I get the following error from javascript console :
document.<formname>.submit() is not a function?

I do not know what I have done that this happen. All the things are correct and work but this.
Reply With Quote
  #4 (permalink)  
Old Jan 4th, 2008, 05:11
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Re: Why this does not work?

Did you have this kind of button somewhere else in your page?
HTML: Select all
<input type="submit" name="submit" value="submit">
if you do, that might be the problem!
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Reply With Quote
  #5 (permalink)  
Old Jan 4th, 2008, 06:14
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Re: Why this does not work?

Quote:
document.<formname>.submit() is not a function?
The reason was the statement "<formname>.submit();" in the javascript was colliding with the form button, which was also named "submit".

Quote:
<input type="submit" name="submit" value="Login">
Sollution: Change the name of the button to "login" or something else more reflective of it’s functionality instead of "submit".

Just guessing here since I don't have your full HTML file.

So your submit function would be like this:
HTML: Select all
function submitForm(formId) {
  var formObj = document.getElementById(formId);
  formObj.submit();
}
and your HTML:
Code: Select all
<a href="http://www.homepage.com"
onclick="submitForm('loginForm'); return false">Login</a>

<form id="loginForm">
<input type="submit" name="login" value="Login">
</form>
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Reply With Quote
  #6 (permalink)  
Old Jan 5th, 2008, 12:00
New Member
Join Date: Jan 2008
Location: My Home
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Why this does not work?

I am very grateful because of your big help. The problem was exactly that and this took one day or more.
Reply With Quote
  #7 (permalink)  
Old Jan 7th, 2008, 04:07
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Re: [SOLVED] Why this does not work?

I am glad it solved your problem!
I beat Rakuli and c010depunkk on this LOL
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Reply With Quote
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript menu - does not work on title page, but does work on other pages Crystal Phoenix Starting Out 4 Mar 24th, 2008 19:40
[SOLVED] Links not working in IE but work in FireFox/Safari skuliaxe Web Page Design 2 Mar 17th, 2008 15:52
[SOLVED] I Cant Get My Thing To Work Proper lung Starting Out 9 Nov 17th, 2007 12:34
simple js doesn't work with IE7 (work with FF1.5) gpazi JavaScript Forum 1 Jun 10th, 2007 11:00


All times are GMT. The time now is 05:37.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43