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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing variables w/ a link tag

Status
Not open for further replies.

NateUNI

MIS
Jan 3, 2002
132
US
I have several (40 variables) that need to be passes when the user clicks on a A HREF tag. Is there a easy way to do this besides appending the variables onto the link? Am i missing something here? Thanks!!
 
The question is:
What are you going to do with the vars on the next page?

If it is:
-) multi page forms, e.g. survey, use sessions to keep the vars alive
-) a script that processes the vars, submit the form with either GET or POST method

Besides these 2 scenarios, is there another one that I don't think of right now? Please tell.
 
You have all sorts of options... but it's going to depend on your limiting factors, they narrow quickly.

Can you count on javascript being enabled on the client computer?

Can you count on being allowed to leave cookies?

Are you sure it has to be an HREF tag, and you can't just use a button?

Are these variables passed to this page, or variables generated on this page?

Is the HREF tag taking you to another of your own pages, if so is it within the same domain?


So basically, I'm thinking of...
javascript to submit a form through an HREF tag (silly but effective)
javascript to modify a button such that it can take you to different locations depending on button (one reason people use HREF's to submit variables)
session variables
and cookies.

-Rob
 
or you could have a load of hidden fields on the form (or an array of some kind) which some JavaScript can populate. If you need the javascript write back but it would be along the lines of assiging an ID attribute to each hidden field and javascript like <formname>.<idname>.value = &quot;what you want&quot;.
Or to save your self some work here, concatante the 40 fields into 1 and put this in a single hiddend field on the form. At the php end split it up again.

I've tussled with the javascript vs non javascript functionality for a while and I've now decided that JS is so good for losts of things that I use it where I can. Which is not to say I have hugh javascript function in my page, if it helps the majority of users get a better experience then i use it. If we coded for the lowest common denomitar we woud write text based sites with html 3.2

(end of soap-box)

kr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top