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

Discussion in 'HTML' started by Noozer, Oct 12, 2004.

  1. Noozer

    Noozer Guest

    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, Oct 12, 2004
    #1
    1. Advertising

  2. Noozer

    Noozer Guest

    "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>
     
    Noozer, Oct 12, 2004
    #2
    1. Advertising

  3. 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
     
    David Dorward, Oct 12, 2004
    #3
  4. Noozer

    Noozer Guest

    > > 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!
     
    Noozer, Oct 12, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. schapopa

    Buttons doens't work

    schapopa, Feb 14, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    372
    schapopa
    Feb 15, 2005
  2. Shapper

    Why this code line doens't work?

    Shapper, Apr 29, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    2,618
    Shapper
    Apr 29, 2005
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,236
    Smokey Grindel
    Dec 2, 2006
  4. Filip De Backer

    System.DirectoryServices doens't work

    Filip De Backer, Aug 26, 2005, in forum: ASP .Net Security
    Replies:
    1
    Views:
    128
  5. Omer Korat

    pickle module doens't work

    Omer Korat, Dec 27, 2012, in forum: Python
    Replies:
    9
    Views:
    179
    Omer Korat
    Jan 2, 2013
Loading...

Share This Page