Just change the code as shown below, I have not checked the code, so some error may occur, for example, capital / small letter. I'm not sure if this is submit () or Submit (), etc.
<script language="javascript"> function submitForm(){ var val = document.myform.category.value; if(val!=-1){ document.myform.submit(); } } </script> <form method="post" name="myform" action="<?php echo $_SERVER['PHP_SELF'] ?>" > <table class="form"> <select name="category" class="formfield" id="category" onchange="submitForm();"> <option value="-1"> Category </option> <?php $sql_contry = "SELECT * FROM category"; $rs_c = mysql_query($sql_contry); while ($row_c = mysql_fetch_array($rs_c)) { echo '<option value="'.$row_c['category'].'">'.$row_c['category'].'</option>'; } ?> </select> </table> </form>
source share