Select variable passed to form
Posted: Fri Nov 06, 2009 8:30 pm
Code: Select all
I'm trying to pass the contents of the select input into the form. It passes "true" as the result. Any idea how i can get it to pass "all" and "friends" depending on which one is selection via the select option input?
Thanks guys,
<?PHP
if(isset($_POST['sort_update'])) {
$sort_update = $_POST['sort_update'];
if(isset($_POST['all'])) { $update_sort = "all"; } if(isset($_POST['friends'])) { $update_sort = "friends"; }
$sql = "UPDATE user_prefs SET sort='$update_sort' WHERE user_id='$user_id'";
$result = mysql_query($sql);
echo $sql;
echo "<br /><br />";
echo $sort_update;
}
?>
<form id="myform" action="index.php" method="post">
Sort By: <select onchange="document.getElementById('myform').submit();">
<option value="all" name="sort_update" elected="selected">Show</option>
<option value="friends" name="sort_update">Show by Friends</option>
<input type="hidden" name="sort_update" value="true">
</select>
</form>