I want to show the result automatically when an option (from Drop Down List) is selected by the user, without using Submit in form, i.e. Just choose the option and the result is here. And by default (if user doen't choose any option and want to see full list) "All" option should be selected.
In my code, only "Strategy" option is showing and also doesn't changing on choosing any other option.
Code is:
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
function selectOption() {
var option = document.form1.genre.value;
if (option == "All") { <? php $abc = mysql_query("select * from games where pc='yes'"); ?>
'games'
is the name of the table in my database
return true;
} else if (option == "Action / Mission") { <? php $abc = mysql_query("select * from games where pc='yes' and genre='Action / Mission'"); ?>
return true;
} else if (option == "Racing") { <? php $abc = mysql_query("select * from games where pc='yes' and genre='Racing'"); ?>
return true;
} else if (option == "Sports") { <? php $abc = mysql_query("select * from games where pc='yes' and genre='Sports'"); ?>
return true;
} else if (option == "Strategy") { <? php $abc = mysql_query("select * from games where pc='yes' and genre='Strategy'"); ?>
return true;
}
return false;
}
</script>
</head>
<body>
<table>
<tr>
<td>
<select name="genre" onChange="selectOption()">
<option value="All">All</option>
<option value="Action / Mission">Action / Mission</option>
<option value="Racing">Racing</option>
<option value="Sports">Sports</option>
<option value="Strategy">Strategy</option>
</select>
</td>
</tr>
</table>
</body>
</html>
I doubt this line
var option=document.form1.genre.value;
Please correct where I m wrong