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
SO网友:Third Essential Designer
像这样填充您的数据,您可以使用Javascript/jQuery来实现这一点。
<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>