Solved

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

Posted on 2004-09-27
7
2,801 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 51

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This video teaches users how to migrate an existing Wordpress website to a new domain.

713 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