Solved

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

Posted on 2004-09-27
7
2,786 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
Comment Utility
try this:
in this line type before u call the function
onClick="javascript:testarea('mainform');">
0
 
LVL 3

Author Comment

by:Felix2000
Comment Utility
Nope didn't make a difference.
0
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 49

Expert Comment

by:Roonaan
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web develope…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now