sanfly Posted February 9, 2007 Share Posted February 9, 2007 Hi, I think I have an easy javascript question here I have a form where people need to select if they have entered a competition in a previous year or not. For selecting previous years, there is a checkbox displayed with the year next to it. WHen a checkbox is selected, it should invoke a function, check if any of the boxes are ticked, then display the link accordingly. What I dont know how to do is check in ANY of the checkboxes are checked. Heres what I have so far <script> function checkLogin(){ var yearChecked = window.document.entryType.prevYear; if(yearChecked.checked == true){ document.getElementById("loginForm").innerHTML = 'You may log in and enter using your previous login details<br><br><a href="loginfail.php">CLICK HERE TO LOG IN AND RE-ENTER</a>'; } else{ document.getElementById("loginForm").innerHTML = 'OR<br><br><a href="enter.php?page=2">CLICK HERE TO ENTER FOR THE FIRST TIME</a>'; } } </script> <form name="entryType"> <table align="center" cellspacing="10"> <tr align="center"> <td colspan="2"> <p class="h3">1. Previous Entries</p> </td> </tr> <tr align="center"> <td> Has your band competed in the WORLD BATTLE OF THE BANDS any of the following years:<br>(please check the appropriate box)<br> <br> <? for($i = 2005; $i < $thisYear; $i++){ ?> <input type="checkbox" name="prevYear[]" value="0" onclick="checkLogin()"> <?=$i?><br> <? } ?> </td> </tr> <tr align="center"> <td id="loginForm">OR<br><br><a href="enter.php?page=2">CLICK HERE TO ENTER FOR THE FIRST TIME</a></td> </tr> </table> </form> Quote Link to comment Share on other sites More sharing options...
fenway Posted February 10, 2007 Share Posted February 10, 2007 You'll have to iterate though them all... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.