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.
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 = "what you want".
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.