Solved

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

Posted on 2004-09-27
7
2,804 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 52

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
Stressed Out?

Watch some penguins on the livecam!

 
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

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!

Question has a verified solution.

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

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

729 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