dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: href submit form with argument

  1. #1
    Join Date
    Sep 2012
    Posts
    3

    href submit form with argument

    Hi,
    I have a form

    <form id="multicity_dl_frm_id" name="multicity_dl_frm_name" action="/link" method="post">

    which i should submit with <a href=""> link </a>
    however there are multiple <a> tags and each should have its own value to submit (id).

    <a href=""> link1 </a> <a href=""> link2 </a>

    is it possible to submit this POST form with value from href using javascript ?

    And values are not the link names, but the ID's (1,2,3,4,...)

    So finally when the "link2" is clicked , to submit the form with value "2" for example.

    Thanks

  2. #2
    Join Date
    Mar 2009
    Posts
    452
    hmm you may try

    <a href="#" onclick="document.getElementById('multicity_dl_frm_id').action='link?id=1';document.getElementById(' multicity_dl_frm_id').submit();">ID 1</a>

  3. #3
    Join Date
    Sep 2012
    Posts
    3
    Actually the url should remain the same, and no arguments should be forwarded with ?id (get method)
    Maybe <a href="#" onclick="here the code to send ID to submit post form" id="2"> link 2 </a>
    ?
    Thanks

  4. #4
    Join Date
    Mar 2009
    Posts
    452
    create a hidden field

    <input type="hidden" id="id" name="id" />
    <a href="#" onclick="document.getElementById('id').value=1;document.getElementById(' multicity_dl_frm_id').submit();">Link 1</a>

    hope it works,

  5. #5
    Join Date
    Sep 2012
    Posts
    3
    That worked !!
    Thank you !

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles