簡體   English   中英

按鈕點擊功能不起作用

[英]Button click function is not working

我對此有一個簡單的疑問,在下面的代碼中,我試圖根據選擇選項菜單中選擇的值打開不同的頁面到目標框架。 但是頁面沒有重定向到框架,我知道某個地方犯了一些愚蠢的錯誤,有人可以幫我嗎?

<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>

使用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'
}
}

首先將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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM