我对此有一个简单的疑问,在下面的代码中我试图根据在选择选项菜单中选择的值打开不同的页面到我的目标帧。但页面没有重定向到框架,我知道在某处做了一些愚蠢的错误,有人可以帮帮我吗?
<script type="text/javascript">
function showcity(select){
if(select.value == 'maha')
{
show();
}
else
{
hide();
}
}
function show(){
var city=document.getElementById('city');
city.style.display ='inline';
}
function hide(){
var cityhide =document.getElementById('city');
cityhide.style.display ='none';
}
function changemap(select){
var maps=document.getElementById('city');
if(maps.select.value == 'mumbai'){
window.location = 'bank_atm_locator_mumbai.html';
}
else if(maps.select.value == 'aura'){
window.location == 'bank_atm_locator_aurangabad.html'
}
else if(maps.select.value == 'pune'){
window.location == 'bank_atm_locator_pune.html'
}
}
</script>
</head>
<body>
<div data-role="page" id="pageone" data-theme="b" onload="hide(this)">
<div data-role="main" style="padding-top: 4em">
<div class="ui-field-contain" align="center" data-theme="a">
<form>
<select name="state" onchange="showcity(this)">
<option value="1" selected="selected">Select State</option>
<option value="maha">Maharashtra</option>
<option value="3">Karnataka</option>
<option value="4">Kerala</option>
</select></form>
</div>
<div class="ui-field-contain" align="center" data-theme="a">
<form><select name="city" id="city" >
<option value="1" selected="selected">Select City</option>
<option value="mumbai" >Mumbai</option>
<option value="aura">Aurangabad</option>
<option value="pune">Pune</option>
</select> </form>
</div>
<a href="#" target="mapview" data-role="button" data-theme="a" onclick="changemap(this)">Go</a>
</div>
</div>
</body>
答案 0 :(得分:1)
使用window.location.href
重定向
function changemap(select){
event.preventDefault();
var maps=document.getElementById('city');
if(maps.value == 'mumbai'){
window.location.href = 'bank_atm_locator_mumbai.html';
}
else if(maps.value == 'aura'){
window.location.href == 'bank_atm_locator_aurangabad.html'
}
else if(maps.value == 'pune'){
window.location.href == 'bank_atm_locator_pune.html'
}
}
答案 1 :(得分:0)
首先将var city保持在show之外并隐藏范围
function showCity(select)
{
//code
var city = document.getElementById('city');
function show()
{
city.style.display = 'inline';
}
function hide()
{
city.style.display = 'none';
}
}