#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    1
    Rep Power
    0

    A href submit post value


    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
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,188
    Rep Power
    184
    Code:
    <script>
    function linkSend(hrefID)
    {
    var linkID = hrefID.substring(hrefID.length-1);
    document.getElementById("form"+linkID+"").submit();
    }
    </script>
    
    <form id="form1" action="form_results.php" method="post">
    <!-- form fields here -->
    </form>
    
    <a id="link1" href="#" onclick="linkSend(this.id); return false">Submit</a>
    Last edited by web_loone08; September 23rd, 2012 at 12:02 AM.

IMN logo majestic logo threadwatch logo seochat tools logo