Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2011
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Best way to send user to url based on selected values?

    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.

  • #2
    Regular Coder
    Join Date
    Apr 2010
    Posts
    103
    Thanks
    2
    Thanked 15 Times in 15 Posts
    javascript sounds like your best option in this scenario, use location.href

  • #3
    New Coder
    Join Date
    Jun 2011
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question

    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?

  • #4
    New Coder
    Join Date
    Jun 2011
    Posts
    12
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Can anyone tell me why the following code is not working when it is called?

    Code:
    function goToStock(){
    	if (document.getElementById("top_search").value=="used") {
    		location.href='http://www.mysite.co.uk/used-cars/';
    	}
    	if (document.getElementById("top_search").value=="van") {
    		location.href='http://www.mysite.co.uk/used-vans-trucks/';
    	} 
    	if (document.getElementById("top_search").value=="bike") {
    		location.href='http://www.mysite.co.uk/used-bikes/';
    	} 
    	if (document.getElementById("top_search").value=="nearlynew") {
    		location.href='http://www.mysite.co.uk/nearly-new-cars/';
    	} 
    	if (document.getElementById("top_search").value=="motability") {
    		location.href='http://www.mysite.co.uk/motability/';
    	} 
    }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •