Forum Moderators: coopster

Message Too Old, No Replies

Testing Value of DropDown Box

         

theriddla1019

3:59 pm on Mar 3, 2004 (gmt 0)

10+ Year Member



Hey im setting the value of a dropdown box with :

$Result2 = mysql_query($Query2, $Link);
?>
<option value="" selected>All</option>
<?
while ($Row2 = mysql_fetch_assoc ($Result2))
{
?>
<option value="<?=$Row2['eFrom']?>"><?=$Row2['eFrom']?></option>
<?
}
mysql_free_result($Result2);
?>

Theres more around it just a brief snippet, it loads fine after this is loaded im trying to test the value of the selected field. and well it doesnt seem to want to test with the code below. ive been looking and i cant find the correct syntax to test it. here is what im using anyone know the correct way to test this?

if (patient_orders.criteria.value == "") {
$search="blehbleh";
}

--->form name is patient_orders
--->select name is criteria

ahmed

4:18 pm on Mar 3, 2004 (gmt 0)

10+ Year Member



if the form's being submitted using POST (method="post" in the form's attributes) then you can access the value of criteria like this :

if ($_POST['criteria'] == "")
$search = 'blah';

jonknee

7:50 pm on Mar 3, 2004 (gmt 0)

10+ Year Member



Looks like you're coming from JavaScript... Form variable names in PHP keep the names you give them in HTML. You just have to import them through either the GET or POST global variable. Example:

$value = $_GET['value'];

or as it has already been shown:

$value = $_POST['value'];

theriddla1019

8:11 pm on Mar 3, 2004 (gmt 0)

10+ Year Member



I guess i was thinking too much java, i was hoping to figure out a way to pass the selected value to the variable without having to post the value, so i ended up posting to a work page that gathered the values and reposted back to the same page with a search button. Trying to keep the extra pages to a min but ya gotta do what ya gotta do.