Go Back   Velocity Reviews > Newsgroups > HTML
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

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

 
Thread Tools Search this Thread
Old 10-12-2004, 05:10 PM   #1
Default Javascript to submit a form... Why doens't it work?


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
  Reply With Quote
Old 10-12-2004, 05:49 PM   #2
Noozer
 
Posts: n/a
Default Re: Javascript to submit a form... Why doens't it work?


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



  Reply With Quote
Old 10-12-2004, 06:20 PM   #3
David Dorward
 
Posts: n/a
Default Re: Javascript to submit a form... Why doens't it work?

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
  Reply With Quote
Old 10-12-2004, 06:50 PM   #4
Noozer
 
Posts: n/a
Default Re: Javascript to submit a form... Why doens't it work?

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


  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump