hi alllll

i have a form that i want to email it, the form is working except that iam not able to get the reuslts of some input types like radio, select, and checkboxes

other than that,everything seems to be fine, im getting the form through my email with the submitted results.

in my code for select boxes

<? echo "<input type=select name=grade>
<option>-----</option>
<option>exellent</option>
<option>good</option>
<option>bad</option>";
?>

HOW can i set SELECTED to the Slected option?

<?echo "Gender <input type=radio name=gener value=M> <input type=radio name=gender value=F>";
?>

HOW can i set CHECKED to the checked option?

thanks indeeeeeeeeed :o

    Do you mean you want to know how the results of those fields are being received by the script? Have a look at the array of values you are getting; the answer should be there.

    Or do you mean you want to display the page with certain options already selected? http://www.w3.org/TR/html4/interact/forms.html

      essentially, you just do a check for each option. using a loop is a good idea otherwise you will need to write a lot of repetative code

      
      $options = array(
          '---',
          'good',
          'bad',
      );
      
      $menu = "<select name=\"grade\">\n";
      
      foreach ($options as $option) {
          $selected = ($_POST['grade'] == $option) ? ' selected="selected"' : '';
          $menu .= "<option value=\"$option\"$selected>$option</option>\n";
      }
      
      $menu .= "</select>\n";
      
      
      

        iam working on it, as i have lot of option boxes in one page

        :-) thanks indeed

          thanks allllooot... it did work just perfectly ;-)

            Write a Reply...