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:
$sql    'SELECT * FROM `Drug` ';
$result mysql_query($sql);
    if (
mysql_num_rows($result) == 0)
" -- No patients found -- ";
    else {
"<select name=\"drugid\">/n";
"<option value=\"\"> </option>\n";
        while (
$r mysql_fetch_array($resultMYSQL_ASSOC))
"<option value=\"" $r['ref'] . "\">" $r['ref'] . " : " $r['name'] . " " $r['dose'] . "</option>\n";
<br><br><input name="submit" id="formbutton" type="submit" value="Prescribe"/>

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:

	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;
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!