Login Retreive lost passwordRegister
Search

Forum Index / General / Check if value in select field is selected

[ This topic is solved ]

  Martin Voelkening 12 February 09 / 06:48  
Hi,

I want to have a select field like that with the following choices:

>> please select
Option 1
Option 2
Option 3

How can I check that the user has selected one of the options and not the first entry '>> please select'?

Thanks

Martin

  Johan Wiegel (Admin) 12 February 09 / 07:33  
that is only posible when the first option has no value.

  Martin Voelkening 12 February 09 / 07:43  
Thanks. How do I get it to have no value?

I use the following code:

$arraysplit = split("\r\n", $form_setup_values);
$number = count($arraysplit);
$l = 0;
while ($l < $number) {
$value = $arraysplit[$l];
$array[$value] = $value;
$l++;
}

if ($form_setup_required == 'Y') {
$check = FH_NOT_EMPTY;
$form_setup_caption = "<strong>" . $form_setup_caption . "</strong>";
} else {
$check = "";
}
$value = $form_setup_default;
$form->SelectField("$form_setup_caption", "$form_setup_db", $array, $check);
if ($form_setup_helptext)
$form->setHelpText("$form_setup_db", $form_setup_helptext);
if ($value)
$form->setValue("$form_setup_db", "$value");
$form->setErrorMessage("$form_setup_db", "$form_setup_error");

  Johan Wiegel (Admin) 12 February 09 / 07:54  
$array['']= 'option 1';
$array['2'] = 'option 2'

and than use the keys as a value (5th argument of a selectfield)

that is exactly why most people use a please select, that is the option without a value.

  Top


powered by PHP-GLOBE   © 2004 - 2012 FormHandler. All rights reserved.   -   Open source license