I have a select menu created by a foreach loop. I am trying to
validate that there was a selection made before it is submitted to the
database. But I am not doing something correctly.

<select name="market" class="ajax"
onchange="javascript:get(this.parentNode);">
<option value="">Choose...</option>
<?php                                   
    foreach($market_prefix as $key => $value)
        {
        $selected = '';
        if($value == $market)
        {
        $selected = 'selected';
        }
        echo '<option value="', htmlspecialchars($value), '" ', $selected,
'>', htmlspecialchars($market_name[$key]), '</option>';
        }
        ?>
</select>

I am using the folling on the posted page.

if (! array_key_exists($_POST['market'], $market_name))
{
    echo "You did not select a market.";
}

Thank you,

Chris

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to