Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing variables and data through a regular web page link?

I'm working with a page where I'm trying to submit data when a link is clicked. I already know how to do this with POST and GET using javascript buttons, but how do I get the same effect when I'm working with HTML links?

like image 555
chustar Avatar asked Mar 21 '09 07:03

chustar


People also ask

How do you pass a variable in a link?

To add a URL variable to each link, go to the Advanced tab of the link editor. In the URL Variables field, you will enter a variable and value pair like so: variable=value. For example, let's say we are creating links for each store and manager.

Which method will pass the values via URL?

Submitting form values through GET method A web form when the method is set to GET method, it submits the values through URL. So we can use one form to generate an URL with variables and data by taking inputs from the users.


1 Answers

If you have a plain link you can pass them as query parameters on the link (which is a GET operation)

<a href="/myapp/somecontroller.php?id=17&name=fred">Save</a>

If you have a plain HTML form with no javascript to handle the button press you can put things in hidden fields

<form name="theform" method="post" action="/myapp/somecontroller.php">
<input type="hidden" name="id" value="17">
<input type="hidden" name="name" value="fred">
 ...
</form>

This doesn't require any javascript.

like image 152
Stephen P Avatar answered Nov 02 '22 07:11

Stephen P