tags:

views:

90

answers:

4

I'm not sure if this is even possible. But I was wondering if anyone knows how to make a hyperlink pass some variables and use POST (like a form) as opposed to GET.

+5  A: 

You create a form with hidden values to post, set action to the destination url and method to get, then you have your link call a javascript function which just submits the form.

See here, for an example: http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml (this example uses pure js, with no jquery -- you could choose this if you don't want to install anything more than you already have)

Palantir
+1  A: 

This is not possible using raw HTML, although you could use jQuery to add a click event handler to the link that could use the post function to issue the POST.

Justin Ethier
+2  A: 

You can use javascript functions. JQuery has a nice post function built in if you decide to use it:

JQuery Post

<script language="javascript"> 

   function DoPost(){
      $.post("WhateverPage.php", { name: "John", time: "2pm" } );  //Your values here..
   }

</script>


<a href="javascript:DoPost()">Click Here</A> 
AGoodDisplayName
A: 

First ask yourself if what you are doing is the correct way of doing it. Then if you are sure, then you can use one of the js solutions shown here.

Ólafur Waage