![]() |
|
|
|||||||
![]() |
HTML - Javascript to submit a form... Why doens't it work? |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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> Noozer |
|
|
|
|
#2 |
|
Posts: n/a
|
"Noozer" <> wrote in message news:TlTad.723596$gE.376502@pd7tw3no... > 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> |
|
|
|
#3 |
|
Posts: n/a
|
Noozer wrote:
> 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. -- David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/> Home is where the ~/.bashrc is |
|
|
|
#4 |
|
Posts: n/a
|
> > 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. Doh!!! Do I feel dumb now... > > <a href="#" onclick="applyBranch('0'); return false;">Branches</a> > > 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! |
|