Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Global Values Passed with form submit

Status
Not open for further replies.

rob51383

Programmer
Jun 23, 2004
134
US
Currently I am passing numerous global values from page to page through the URL (?value=value&....). I would like to pass them with <form method="post"> so they do not display in the URL but I am using <a href> links.

I know you can create a javascript generic form submitter but I would like to take it a step further. I want to avoid having to print a hidden input box for each link for each global value.

So what I need to do is have a farm of hidden boxes with the global values that get sent when you click a link like this:

You click this link:
<a href="script.php" id="2">Click Here</a>

And the values of this generic form are sent:
<form>
<input type="hidden" name="gv1" value="Global Value 1">
<input type="hidden" name="gv2" value="Global Value 2">
<input type="hidden" name="gv3" value="Global Value 3">
<input type="hidden" name="id" value="(a href id)">
</form>

So when you click the link the form "id" input box value is updated with "2" and the form is sent to the php script called in the <a href> tag.

Thanks in advanced for any help.
 
I think that using an HREF will cause you to lose your form data as the form is not submitted.

An alternative would be to use something like this.
<span onmouseover="this.style.cursor='hand'; this.style.color='0000A0'" onmouseout="this.style.cursor='auto'; this.style.color='black';" onclick="myfunction(1)">My first link</span>

The text in the span will act like an anchor tag but call a javascript function. In your function you can submit the form via code. You just need to set your form action and method in the HTML.

You could easily setup a style to control the mouseover/mouseoff bits rather than building them into each of the psuedo-links, this was just a quick way to show you how it could be done.

Others may have better approaches but the above should work for you.

Paranoid? ME?? WHO WANTS TO KNOW????
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top