Javascript to submit a form... Why doens't it work?

N

Noozer

For some reason I am not able to submit my form using javascript. In IE (my
target browser), with the code below I get a "Object doesn't suppor this
property or method" error. If I click the submit button (labelled "go") it
works fine.

Any suggestions on how I can submit this form once I'm finished processing
this javascript?


<form name="selections" id="selections" action="mypage.asp" method=post>
<input name="Branch" type=text value=<%=numBranch%>>
<input name="submit" type=submit value="go">
</form>

<a href="#" onclick="applyBranch('0'); return false;">Branches</a>

<script language=javascript type="text/javascript"> <!--
function applyBranch(val) {
selections.elements['Branch'].value = val;
selections.submit();
}
--></script>
 
N

Noozer

Noozer said:
For some reason I am not able to submit my form using javascript. In IE (my
target browser), with the code below I get a "Object doesn't suppor this
property or method" error. If I click the submit button (labelled "go") it
works fine.

Also tried to use:
document.getElementById("selections").submit();
....with the same results.

I probably have a typo elsewhere in the page (missing bracket, etc.)
throwing something off, but I can't find it.

I've noticed that other functions that worked fine are also failing.. This
function used to work without a problem:

function showhide(objID) {
if (document.getElementById(objID).style.display == "none") {
document.getElementById(objID).style.display = "block";
} else {
document.getElementById(objID).style.display = "none";
}
return false;
}

Now I'm really confused...
Any suggestions on how I can submit this form once I'm finished processing
this javascript?


<form name="selections" id="selections" action="mypage.asp" method=post>
<input name="Branch" type=text value=<%=numBranch%>>
<input name="submit" type=submit value="go">
</form>

<a href="#" onclick="applyBranch('0'); return false;">Branches</a>

<script language=javascript type="text/javascript"> <!--
function applyBranch(val) {
selections.elements['Branch'].value = val;
selections.submit();
}
--></script>
 
D

David Dorward

Noozer said:
For some reason I am not able to submit my form using javascript.
<form name="selections" id="selections" action="mypage.asp" method=post>
<input name="Branch" type=text value=<%=numBranch%>>
<input name="submit" type=submit value="go">
</form>

You have an input named submit, this conflicts (and overrides) with the
submit method of forms.
<a href="#" onclick="applyBranch('0'); return false;">Branches</a>

Yuck.

<a href="mypages.asp?Branch=0">Branches</a>

No need for unreliable JavaScript.
 
N

Noozer

For some reason I am not able to submit my form using javascript.
You have an input named submit, this conflicts (and overrides) with the
submit method of forms.

Doh!!! Do I feel dumb now...
Yuck.

<a href="mypages.asp?Branch=0">Branches</a>

No need for unreliable JavaScript.

Add another 15 fields to that form and it gets more complicated.

I am considering generating the links using ASP instead of using the form
though... That would elminate the need for Javascript for this test. Just
need to make sure that using the "get" method instead of "post" to carry the
data over will be OK.

....now to figure out what else I broke while troubleshooting. : (

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top