[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2004-09-27
7
Medium Priority
?
2,808 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 53

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
Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

 
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 200 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

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
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 tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Suggested Courses

656 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