Can we click a link and it will submit the form to the other page?

Discussion in 'Javascript' started by Matt, Sep 22, 2004.

  1. Matt

    Matt Guest

    Can we click a link and it will submit the form to the other page?
    Usually we will submit the
    form to other page by clicking a submit button.

    Now I need to do the following, but what if I have many data in the
    form? Any workarounds?
    <a href="http://myserver/index.jsp?name=test&actionType=test"
    target="_blank">Add New Document</a>

    Please advise. thanks!!
     
    Matt, Sep 22, 2004
    #1
    1. Advertisements

  2. Matt

    Randy Webb Guest

    Re: Can we click a link and it will submit the form to the otherpage?

    Matt wrote:

    > Can we click a link and it will submit the form to the other page?
    > Usually we will submit the
    > form to other page by clicking a submit button.
    >
    > Now I need to do the following, but what if I have many data in the
    > form? Any workarounds?
    > <a href="http://myserver/index.jsp?name=test&actionType=test"
    > target="_blank">Add New Document</a>
    >
    > Please advise. thanks!!


    Why not just use a submit button and be done with it?

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq
     
    Randy Webb, Sep 22, 2004
    #2
    1. Advertisements

  3. Matt

    kaeli Guest

    In article <>,
    enlightened us with...
    > Can we click a link and it will submit the form to the other page?
    > Usually we will submit the
    > form to other page by clicking a submit button.
    >
    > Now I need to do the following, but what if I have many data in the
    > form? Any workarounds?
    > <a href="http://myserver/index.jsp?name=test&actionType=test"
    > target="_blank">Add New Document</a>
    >
    > Please advise. thanks!!
    >


    Yes, but note that it can die in non-supporting browsers. I don't recommend
    it for the 'net.
    Intranet is fine.

    This is what I do.

    -- actual code from generated page, modified for sensitive content --

    <td>
    <form name='otFrm11' action='admnType.jsp' method='get'>
    <input type='hidden' name='Type' value='WIRELESS'><input type='hidden'
    name='description' value='Wireless'><input type='hidden' name='status'
    value='1'></form>
    <a href="javascript:document.forms['otFrm11'].submit();">WIRELESS</a></td>

    -- end code --

    Note that I am using the javascript protocol for a link. This is not
    recommended for general use and is not very cross-browser. This works in IE6
    and NN7, the only browsers I need to care about. If you need it more cross-
    browser, remove the script from the href and put it in onClick and put a real
    location in the href.
    <a href="someNonJsPage.html" onClick="document.forms['formname'].submit()">

    If the submit (target of the form or a function that opens a new window and
    sets target) is to a different window, add "return false" to the onClick so
    the href isn't followed in the main page.
    <a href="someNonJsPage.html" onClick="document.forms['formname'].submit();
    return false;">

    HTH
    --
    --
    ~kaeli~
    He's your God, they're your rules - you burn in Hell.
    http://www.ipwebdesign.net/wildAtHeart
    http://www.ipwebdesign.net/kaelisSpace
     
    kaeli, Sep 22, 2004
    #3
    1. Advertisements

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. Mark
    Replies:
    1
    Views:
    1,857
  2. Matt
    Replies:
    1
    Views:
    586
    David Dorward
    Sep 22, 2004
  3. Charles Siegel
    Replies:
    0
    Views:
    385
    Charles Siegel
    Feb 19, 2006
  4. Benny Ng
    Replies:
    4
    Views:
    3,085
    Benny Ng
    May 23, 2006
  5. Replies:
    3
    Views:
    866
Loading...

Share This Page