0

I have a site with a database of repair shops, by; Manufacturer - Venue

I want 2 dropdown lists at the home page.

In the first dropdown, when i select the "Apple" the second list appears in the places where they are "Apple" repair shops, and when i press the "Submit" button, it redirects me to its page.

Like; When i select in the first dropdown "Apple" It lists: -1 -2 -3 -4 -5 -6 -7

When i select "7" and press "SUBMIT" redirect to: mysite.com/7.

How can i do it?:l

1 Answer 1

1

Populate your data something like this and and you can use Javascript/jQuery to achieve this.

<select class='apple_store_location'>
<option value='1' data-url="http://mysiteurl.com/1"> Place 1</option>
<option value='2' data-url="http://mysiteurl.com/2"> Place 2</option>
<option value='3' data-url="http://mysiteurl.com/3"> Place 3</option>
<option value='4' data-url="http://mysiteurl.com/4"> Place 4</option>
<option value='5' data-url="http://mysiteurl.com/5"> Place 5</option>
<option value='6' data-url="http://mysiteurl.com/6"> Place 6</option>
<option value='7' data-url="http://mysiteurl.com/7"> Place 7</option>
</select>

<script>
//Using jQuery
jQuery(document).ready(function($) {
    $('.apple_store_location').change(takeMe2URL);
    function takeMe2URL() {
       var new_url =  $('option',this).data('url');
       window.location.replace(new_url);
    }
});

</script>
2
  • This probably can be built dynamicly depending on where meta data is provided.
    – klewis
    Commented Nov 12, 2016 at 16:08
  • Of course. It will be build dynamically. But the jQuery/Javascript thing work on front end and has the above look. Commented Nov 14, 2016 at 7:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.