I've got a form that appears such as this:

$guests = 2; // Just for testing
$form = 'Guests<br /><select name="guests">
             <option value="0">0</option>
             <option value="1">1</option>
             <option value="2">2</option>
             <option value="3">3</option>
             <option value="4">4</option>
             <option value="5">5</option>
             <option value="6">6</option>
             <option value="7">7</option>
             <option value="8">8</option>
             <option value="9">9</option>
             </select>';

However the listing of visitors can depend on 100, and so i most likely should not perform a look for which value is chosen by hand.

What will be a great way that i can result in the selected value end up being the selected value once the user sees this type?

Thanks!

Things I normally use dynamic choose menus is make use of a foreach loop over an assortment, and merely check the items.

Something similar to:

$dropdownName = "guests"; //Name of dropdown
$defaultValue = "0"; //value to select if there isn't one already set
$items = array('name'=>'value', 'anotherName'=>'anothervalue'); //items, name=>value

echo '<select name="'.$dropdownName.'">'; //Start Select

$selectedItem = (isset($_POST[$dropdownName])?$_POST[$dropdownName]:$defaultValue); //If a value is set, use it, otherwise use the default

foreach ($items as $name=>$value) //build select
{
    echo '<option value="'.$value.'"'.(($selectedItem == $value)?' selected="selected"':'').'>'.$name.'</option>';
}
echo '</select>';
$guests = 2; // Just for testing
$form = 'Guests<br /><select name="guests">';

for($i = 0; $i <= 100; $i++)
    $form .= "<option value='$i'{$guest == $i ? ' selected=\'selected\'' : ''}>$i</option>";

$form .= '</select>';

EDIT: $i < 101 was pretty lame...

You are able to keep value this value inside a hidden area as well as on document.ready(), you are able to assign the chosen worth of drop lower top the need for hidden value.

An answer that actually works but might not be efficient for many customers...