[英]Button click function is not working
I have a simple doubt over here, in below code I am trying to open different pages to my target frame according to the values selected in select option menu. 我对此有一个简单的疑问,在下面的代码中,我试图根据选择选项菜单中选择的值打开不同的页面到目标框架。 But the pages are not redirecting to the frame , I know have done some silly error somewhere , can anybody please help me ? 但是页面没有重定向到框架,我知道某个地方犯了一些愚蠢的错误,有人可以帮我吗?
<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>
use window.location.href
to redirect 使用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'
}
}
start by keeping the var city out of the show and hide scope as so 首先将var city排除在显示范围之外,然后隐藏范围
function showCity(select)
{
//code
var city = document.getElementById('city');
function show()
{
city.style.display = 'inline';
}
function hide()
{
city.style.display = 'none';
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.