Solved

Javascript to submit a form... just doesn't work argh!!!

Posted on 2004-09-27
7
2,792 Views
Last Modified: 2007-11-27
Just looking to do a simple thing and have javascript submit a form when another button is pressed.  For some reason it stopped working can't even get it to work in my little test script... I'm sure it's something simple that I'm missing but can't figure it out.

The variables are being passed fine I can do alert and see a bunch of info on the object but it gives
"object doesn't support this property or method"

http://felix2000.myftp.org:8080/gcc/test2.html
0
Comment
Question by:Felix2000
7 Comments
 
LVL 1

Expert Comment

by:manuel2004
ID: 12166014
try this:
in this line type before u call the function
onClick="javascript:testarea('mainform');">
0
 
LVL 3

Author Comment

by:Felix2000
ID: 12166112
Nope didn't make a difference.
0
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 12166382
try:

<html>
<head>

<script language="JavaScript1.2">

function testarea( frm )
{
       frm.submit();
}

</script>
</head>
      <body>

<form name="mainform" id="mainform"  method="post" action="/cgi-bin/editshift.pl">

<textarea name="area1" id="area1" style="width:650; height:200;" ></textarea>
<br>
<input name="something" type="button" value="Java Submit" onClick="testarea(document.mainform);">
<input name="submit" type="submit" value="Regular Submit">
</form>

      </body>
</html>
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 49

Expert Comment

by:Roonaan
ID: 12167929
Try the code below. This would be safer then using getElement.

Regards

-r-

<html>
<head>

<script type="text/javascript">


function testarea( obj )
{
        //alert(divtag.id);
      //alert(divtag.name);
      //alert(divtag.method);
      //alert(divtag.action);
      obj.submit();


}

</script>
</head>
      <body>

<form name="mainform" id="mainform"  method="post" action="/cgi-bin/editshift.pl">

<textarea name="area1" id="area1" style="width:650; height:200;" ></textarea>
<br>
<input name="something" type="button" value="Java Submit" onClick="testarea(this.form);">
<input name="submit" type="submit" value="Regular Submit">
</form>

      </body>
</html>
0
 
LVL 3

Author Comment

by:Felix2000
ID: 12170306
This is very strange, I have the same function working in another script with tons more code and it won't work now with the basics.
Does this work for anyone else? Or is it just me?

I'm using IE 6 but also tested in Mozilla these are the errors I get from the javascript console

Error: uncaught exception: [Exception... "Cannot convert WrappedNative to function"  nsresult: "0x8057000d (NS_ERROR_XPC_CANT_CONVERT_WN_TO_FUN)"  location: "JS frame :: file:///C:/GCC%20Shift%20Summary/test5.htm :: testarea :: line 8"  data: no]

or this

Error: obj.submit is not a function
Source File: http://felix2000.myftp.org:8080/gcc/test4.html
Line: 14
0
 
LVL 15

Accepted Solution

by:
joeposter649 earned 50 total points
ID: 12170587
Change the name on the "Regular Submit" button...
<input name="regsubmit" type="submit" value="Regular Submit">
or
<input name="Submit" type="submit" value="Regular Submit">

0
 
LVL 3

Author Comment

by:Felix2000
ID: 12170645
LOL thats works... joeposter649!
IE/javscript must have some wierd bug relating to the name of the input submit button.
Thanks know I know I was missing something small.

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
modify h2 4 116
what are list of ebay api errors 1 19
Scroll 5 news at a time. 4 28
specific navigation button disappears on mobile devices 1 17
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

823 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question