Hi,

Javascript below doesn't work. It always retuns false. Where is mistake?

thanks

<script Language="JavaScript">
	function validateAreas(){
		if (document.form1.selectS.value=="") {
			alert("Please select a S");			
			form1.selectS.focus();
			return false;
		}
		return true;
	}
	</script>	


<form name="form1" method="post" action="" onSubmit="return validateAreas();">
.....

<select name="selectS">
    	<option selected="selected"></option>
		<?php
		$q="SELECT id  FROM spp";
		$run=mysql_query($q);
		if (@mysql_num_rows($run)>0) {
			while ($new=mysql_fetch_array ($run, MYSQLI_ASSOC)) {
		?>
	    	<option><?php echo $new['id']; ?></option>
		<?php
			}
		}
		?>
      </select>
<input type="submit" name="Submit" value="Send">

Solved.
I have forgotton to add value for options.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.