View Full Version : Best way to send user to url based on selected values?

06-13-2011, 08:55 PM
I have a form which contains a few drop down lists.
The contents of the dropdown lists are dependent on each other and are populated via php scripts which are called each time a selection is made or changed by the user.

When the view results button is clicked in the form I need the user to be directed to a specific page based on the selections they have made.

The url of the page they need to be directed to is really based on what has been chosen in the first dropdown. The subsequent dropdowns form variables that I need to be sent to the page so that the data the user sees on that page is relevant.

ie if the user has chosen bikes then a specific manufacturer then a specific price range the page they will be sent to will be the bike.php page with all the manufacturer specific bikes in their chosen price range visible. Can anyone tell me the best way to go about doing this please?

I had thought about using the php header script along with an if statement but how do I then go about getting the variables sent to the page to be recognised?

Would I be better looking at the window.location in js to do this?

Any help and advice would be greatly appreciated on this. I can post the code for the form if that makes any difference.

06-13-2011, 08:58 PM
javascript sounds like your best option in this scenario, use location.href

06-13-2011, 09:28 PM
Thanks for the super quick reply, would you be able to give me an example of how I'd need to set up the code for this to work please?

06-13-2011, 09:57 PM
Can anyone tell me why the following code is not working when it is called?

function goToStock(){
if (document.getElementById("top_search").value=="used") {
if (document.getElementById("top_search").value=="van") {
if (document.getElementById("top_search").value=="bike") {
if (document.getElementById("top_search").value=="nearlynew") {
if (document.getElementById("top_search").value=="motability") {