Hi, I am extremely new to Javascript and have stumbled along a validation problem. My form is below:

<form name="validate" action="<?php echo $pfile;?>" onsubmit="return Validate()" method="post">
<input type="hidden" name="patientid" id="drugnames" value="<?php echo $patientid;?>" />

PHP Code:
  
   $currentdrug 
$_SESSION['prescribed'];
 
    
    
$sql    'SELECT * FROM `Drug` ';
    
$result mysql_query($sql);
    
   
    
    if (
mysql_num_rows($result) == 0)
        echo 
" -- No patients found -- ";
    else {
        echo 
"<select name=\"drugid\">/n";
        
        echo 
"<option value=\"\"> </option>\n";
        while (
$r mysql_fetch_array($resultMYSQL_ASSOC))
            echo 
"<option value=\"" $r['ref'] . "\">" $r['ref'] . " : " $r['name'] . " " $r['dose'] . "</option>\n";
        
        echo 
"</select>\n";
    }
    
    
    
    
?> 
<br><br><input name="submit" id="formbutton" type="submit" value="Prescribe"/>
</form>


So basically the php script runs through every drug id and prints out the ref number, name and dose in a option value form. The variable $currentdrug produces a number. This is where my problem lies. I have created a JS function like so:

Code:
  <script>
	function Validate() {
	
	valid = true;
	var previous = document.getElementById('currentdrug').value;

    if ( document.validate.drugid.selectedIndex == 1 && document.validate.previous.value == 5  )
    {
        alert ( "Big Drop" );
        valid = false;
    }

		return true;
	}
  </script>
I am trying to say, if the selected index is 1 and the current drug is equal to 5, an alert is produced, but having no success with this function. any idea on how to amend this? Thanks in advance!