There is a list of stores, when users select a store from dropdown menu, they should go to the specific URL.
Here is the javascript and HTML code but this is not working! What is the problem?
<script>
function pageReady() {
document.getElementById('store-id').onchange = function() {
var URL = "44805?id=57"
document.location = URL;
};
document.getElementById('store-id').onchange();
}
</script>
<script src="/mcs/s/asset/34065/utils.js"></script>
<link rel="stylesheet" href="/mcs/s/file/54985/dialogs.css" media="screen" />
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=true"></script>
Use a jQuery load on a div:
$('#myDiv').load('http://www.someurl.com');
But maybe you want to navigate to a url. If you use a button, you could do:
$('#myButton').click(function(){
var url = $('#store-id').val();
document.location = url;
});
use
$('#Div').load('http://www.google.com');
as a jquery function to load a page in your div.
Imagine this select control (drop-down list):
<select id="store" name="store">
<option value="null"> --- </option>
<option value="1"> Store #1 </option>
<option value="2"> Store #2 </option>
<option value="3"> Store #3 </option>
</select>
Now, you just need the code below in jQuery to navigate your user to the new page.
$(document).ready(function(){
$('#store').change(function(e) {
var target = $('#store').val();
if (target != 'null') window.location = 'something.php?id='+target;
});
});
As the user change your dropdown list, he/she will be navigated to the new page with his/her choice from your control.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.