sanfly Posted August 23, 2007 Share Posted August 23, 2007 Hi all I have a script (below) where different things should happen when checkboxes are selected The first thing is that when you click on the "Band" option, a bunch of new options should appear. This works fine. The second is that when you click on the "All Years" option, it should disable the other years. When I click on this I get an error: document.maillist.bandYears.length is null or not an object Now, I cant figure out why im getting this message. I was wondering if it was something to do with the fact that the bandYears[] checkbox array is put into the form using Javascript, rather than "hard coded"? Or is it something else? Can anyone help? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <script language="JavaScript"> function getBandOptions(){ if(document.maillist.u_group[4].checked == true){ document.getElementById('bandYear').innerHTML = '<b>Year: </b><br></td><td><input type="checkbox" name="bandYears[]" value="all" style="vertical-align: middle;" onClick="disableYears();"> All years<br><input type="checkbox" name="bandYears[]" value="2007" style="vertical-align: middle;"> 2007<br><input type="checkbox" name="bandYears[]" value="2006" style="vertical-align: middle;"> 2006<br><input type="checkbox" name="bandYears[]" value="2005" style="vertical-align: middle;"> 2005<br>'; document.getElementById('bandCountry').innerHTML = '<b>Country: </b></td><td id="countrySelect">'; document.getElementById('bandRegion').innerHTML = '<b>Region: </b></td><td id="regionSelect"><select name="b_region" disabled><option value="SELECT REGION"></select>'; } else{ document.getElementById('bandYear').innerHTML = ""; document.getElementById('bandCountry').innerHTML = ""; document.getElementById('bandRegion').innerHTML = ""; } } function disableYears(){ arrayLength = document.maillist.bandYears.length; if(document.maillist.bandYears[0].checked == true){ for(i = 1; i < arrayLength; i++){ document.maillist.bandYears[i].disabled = true; } } else{ for(i = 1; i < arrayLength; i++){ document.maillist.bandYears[i].disabled = false; } } } </script> </head> <body> <table align="center" class="mainTable" cellpadding="0" cellspacing="0" border="0"> <tr class="headingTr"><td valign="top"><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="440" HEIGHT="200" id="wbotb-map-2007" ALIGN=""><PARAM NAME=movie VALUE="images/wbotb-map-2007.swf"><PARAM NAME=quality VALUE=high><PARAM NAME=bgcolor VALUE=#FFFFFF><param name="wmode" value="transparent"><EMBED src="images/wbotb-map-2007.swf" quality=high bgcolor=#FFFFFF WIDTH="440" HEIGHT="200" NAME="wbotb-map-2007" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" wmode="transparent"></EMBED></OBJECT></td><td valign="top" align="right"><a href="index.php"><img src="images/2007-header-logo-only-black.jpg" width="340" height="200" border="0" title="WORLD BATTLE OF THE BANDS WEBSITE"></a></td></tr> <tr class="navTr"> <td colspan="2" valign="top"> Menu goes here </td> </tr> <tr> <td colspan="2" class="mainContent" valign="top"> <title>WBOB Mailing List</title> <div class="heading"><img src="images/h_send_group_email.png" alt="SEND GROUP EMAIL" width="235" height="30" border="0" title="SEND GROUP EMAIL"></div><br> <form name="maillist" method="post" action="maillist.php?action=sendmail2"> <table> <tr> <td valign="top" align="right" width="90"><b>User Group: </b></td> <td valign="top" width="180"> <input type="checkbox" name="u_group[]" id="u_group" value="1" style="vertical-align: middle;"> Website Administrator<br> <input type="checkbox" name="u_group[]" id="u_group" value="2" style="vertical-align: middle;"> Administrator<br> <input type="checkbox" name="u_group[]" id="u_group" value="3" style="vertical-align: middle;"> Regional Coordinator<br> <input type="checkbox" name="u_group[]" id="u_group" value="12" style="vertical-align: middle;"> Photographer<br> <input type="checkbox" name="u_group[]" id="u_group" value="6" onclick="getBandOptions();" style="vertical-align: middle;"> Band<br> </td> <td valign="top"> <br><br><br><br><br><br> <table cellspacing="5"> <tr> <td valign="top" id="bandYear"></td> <td valign="top" id="bandCountry"></td> <td valign="top" id="bandRegion"></td> </tr> </table> </td> </tr> <tr> <td colspan="3"><hr></td> </tr> <tr> <td colspan="3"> <hr> <br> <input type="button" onclick="history.back();return false;" value="« CANCEL"> <input type="submit" value="PREVIEW »"> </td> </tr> </table> </form> </td> </tr> <tr> <td class="mainFooter" colspan="2"> <table cellspacing="0" cellpadding="0" width="100%" border="0"> <tr> <td> <a href="contacts.php?action=list" class="footerNav">CONTACT US</a> :: <a href="sitemap.php" class="footerNav">SITE MAP</a> All Content © 2007 World Battle of the Bands Ltd </td> <td align="right"> <a href="http://www.intergalacticrecords.com" target="_blank"><img src="images/igr_logo_60.gif" alt="" width="60" height="60" border="0" style="vertical-align: middle;" title="INTERGALACTIC RECORDS"></a> <a href="http://www.sanfly.com" target="_blank"><img src="images/sanfly-mini-logo.gif" title="SANFLY WEB DESIGN" width="76" height="32" border="0" style="vertical-align: middle;"></a> </td> </tr> </table> </td> </tr> </table> </body> </html> 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.