Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8

Thread: a href as POST

  1. #1
    New Coder
    Join Date
    Aug 2006
    Location
    Zurich, Switzerland
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    a href as POST

    Hi all

    Is it possible to transfer data to another page in POST using a link instead a button? Thanks.

    Bart

  2. #2
    Regular Coder
    Join Date
    Jan 2005
    Posts
    155
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i believe you will need javascript on the link to run the submit function, but yes, it can be done.

  3. #3
    New Coder
    Join Date
    Aug 2006
    Location
    Zurich, Switzerland
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your answer.

    I have the following code to choose the right submit-form:

    function OnSubmitForm()
    {
    if(document.pressed == 'xxx')
    {
    document.mydoc.action ="xxx.asp";
    }
    else
    if (document.pressed == 'yyy')
    {
    document.mydoc.action ="yyy.asp";
    }
    return true;
    }

    With buttons that works fine. Now I have also a link on the page. How can I do that the link acts also like a submit button and goes trough the Function OnSubmitForm?

    Thanks
    Bart

  4. #4
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <form name="form1" id="form1" method="post" action="">
      <input type="text" name="textfield" /> 
      <a href="javascript:document.form1.submit()">Submit Form</a>
    </form>
    <%
    If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
      	Response.Write "Form Submitted"
    End

  5. #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You shouldn't really POST data from a link - consider someone who's using a browser that pre-fetches links, when they visited that page it would perform every single link triggered action on the page, with potentially disastrous consequences.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  6. #6
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    plus javascript can be disabled

  7. #7
    New Coder
    Join Date
    Aug 2006
    Location
    Zurich, Switzerland
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The site is part of an intranet and we know all the users. So javascript is not the problem. The users want instead of buttons links on the page - thats why I ask for the submit-action of links.

  8. #8
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    POSTable HTML links

    Recently I stepped in the same problem of having something quite similar to A HREF tag that produces POST instead of GET. And what I have developed:

    http://aujava.wordpress.com/2007/01/...le-html-links/

    JavaScript in 2007 is a MUST! Otherwise you can't use GMAIL

    Sorry for posting a link. There are plenty of code and I do not want to copy-paste it from wordpress.


 

Posting Permissions

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