[thelist] Javascript/Dropdown box detection

CDitty mail at redhotsweeps.com
Tue Sep 9 15:59:11 CDT 2003


I am trying to detect if the user has selected something from a multi drop 
down box and also if they have selected just one item.  I cannot get the JS 
to detect it and to give me an alert.  Can anyone look at the code below 
and tell me what I am doing wrong?

Chris

ps...the brackets on the select box acct[] are needed so php will know how 
to handle the variables on the next page.

JS
<script LANGUAGE="JavaScript">
function multiMeterCheck(form){
         alert('1');
         if(form.acct.options[form.acct.selectedIndex].text == ""){
                 alert('You must select atleast 2 meters.');
         return(false);
         }
         alert('2');
}
</script>

Multi Select box
<form method="get" action="index.php" name="multi" onsubmit="return 
multiMeterCheck(this)">
<input type="hidden" name="USID" value="87ab58294f2260a616ab8a57e21c9bed" />
<input type="hidden" name="fuseaction" value="gas.displayMeterMulti">
<input type="hidden" name="chart" value="multi_bar_">
&nbsp;<font class="news_text_header">Multiple Meters<br></font>
<select name="acct[]" multiple size="4" class="news_text">
<option value="9124cb7f878af48afff9859efcb3320c59b4f013">100010 Adm 
Grain</option>
<option value="71cc5d831bfb1be62ee4cbe702b9317af6cc1b84">100030 Apac - 
Harbor</option>
<option value="abf01a47b97459c99bbca20922bd815014a3a64b">100050 Aratex - 
Primary</option>
<option value="5b3394c2fa0dbd3eef2eeabaec57470269ebd226">100840 Coca 
Cola</option>
<option value="6cd854de8925ecaf04acb57b3d7adec756b738d4">101200 
Dupont-(hydro...</option>
<option value="10bc5953380ea3668da16e67dc998400c4adb129">101190 
Dupont-turbine</option>
<option value="a2e34c0900a36353ee488e74c153b329fe9f0385">100080 Von Drekle 
Pr...</option>
<option value="8be87ab5678c93511b4edc92266123db5a0fb46c">100062 White 
Station...</option>
</select>
<font class="news_text"></font><font class="spacer">&nbsp;</font>
<center><input type="submit" name="submit" value="Chart Multiple Meters" 
class="sidebarbuttons"></center>



More information about the thelist mailing list