简体   繁体   中英

Cannot change to different windows using window.location.href

I am trying to re-direct my code to another page but for some reason It wont allow me too. I have the exact page name but it will not re-direct to that page or any page for that matter. My code is dependant on a user select a radio button that displays either yes or no. Please advise on what my errors are. Thanks

<script type="text/javascript">

function idForm()
{

if(document.getElementById('No').checked) {

alert("Please book a meeting room, before organising catering.");

}

if (document.getElementById('Yes').checked)
{

window.location.href = "homePage.php";


}


 }




</script>

<body>
<div id=""> <img src="" alt="" style="">
</div> 
<div class="verify" style="margin:0 auto;">
<form name="form1" action="" onsubmit="idForm()" method="post">
<!-- Booking Filter -->

 <h1>HAVE YOU BOOKED A MEETING ROOM PRIOR TO ORGANISING CATERING?</h1>

 <input type="radio" id="Yes" name="agree" value="Yes"> Yes
 <input type="radio" id="No" name="agree" value="No"> No<br> <br> <br>
 <input type="submit" class="space" name="Submit" value="Submit"> 

 </form>
</div>

window.location.href is a property not a method. just assign it.

window.location.href = "homePage.php";

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM