Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

document submit problems 1

Status
Not open for further replies.

paulparky

Programmer
Oct 10, 2001
29
PA
I have the following code in an asp webpage

<Script language = &quot;JavaScript&quot;>
function SendToWebServer(action)
{
document.form1.action = &quot;book_in.asp?ContainerNumber=&quot; + document.form1.container_no.value + &quot;&action=&quot; + action;
document.form1.submit();
}
</script>

I get the error &quot;Object does not support this property or method&quot; indicating there is problem with document.form1.submit()

Any one any ideas before I lose my hair completely?
 
Do you have a formed explicitly named &quot;form1&quot;?

<form name=&quot;form1&quot;>


in that form, do you have an input named &quot;container_no&quot;

<input name=&quot;container_no&quot;>

all is case sensitive...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
the form is form1 and the field name container_no - exactly as typed.
 
I've never dynamically set the action element of a form tag before, so I could be totally off base here..... but would you set it like this:
Code:
document.form1.action.
Code:
value
Code:
 = 'blah'

-kaht

banghead.gif
 
The strange thing is that the same piece of code works fine with a different form. In that form the form name is form1 and the field name is also container_no
 
Try commenting out both lines of your function and put in these 2 statements:

if (document.form1) {alert(&quot;form exists&quot;);}
if (document.form1.container_no) {alert(&quot;container exists&quot;);}

If either form1 or container_no is undefined you'll find out which that way.

-kaht

banghead.gif
 
I've already tried this, the form does exist and the container_no value is filled in as expected. As with your logo - I'm banging me head in the wall...!!!!
 
Here's a tool for you,

Throw some of your other stuff in here see if you can
break it. Tested this in IE6 & NN7. Maybe since &quot;action&quot; is
already a document object you should stay away from using
it as a variable... just an idea though.

Code:
<html><head><title>TEST</title>
<script language=&quot;JavaScript&quot;>
function chgfrm(act){
document.f.action = act;
}
</script></head><body>
<form name=&quot;f&quot; action=&quot;&quot;></form>
<input type=&quot;button&quot; value=&quot;test&quot; 
onClick=&quot;chgfrm('[URL unfurl="true"]http://test')&quot;>[/URL]
<input type=&quot;button&quot; value=&quot;see&quot; 
onClick=&quot;alert(document.f.action);&quot;>
</body></html>



Great Javascript Resource:
 
>> &quot;Object does not support this property or method&quot;

This error is most likely because you have a form submit button, or some other form element with a name of &quot;submit&quot; (
Code:
<input type=&quot;button&quot; name=&quot;submit&quot; onClick=&quot;xxx&quot;>
...)

10 pounds says you do ;o)

Javascript thinks you're trying to access the form element named submit, instead of calling the submit method of the form. Rename your rogue element, and all will be well again.

Dan
 
Dan (BillRayPreachersSon???)

Seems I owe you a tenner :eek:)

There was indeed a button named &quot;Submit&quot; within the form. As you say all is well again now.

Ta.

paulparky
 
Good catch BillRayPreachersSon - I'm guessing Paul isn't familiar w/ the star system - so I'll give you one for him...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top