Jump to content

changing radio buttons in PHP


chwebdesigns

Recommended Posts

I have this code, which I have got off the internet. What I want to do is instead of having the radio buttons, is to have a drop down menu. I have made it but unfortunately it doesn't work.

Here is part of the code for the radio buttons:

echo '<label for="rate5_'.$rater_id.'"><input type="radio" value="5" name="rating_'.$rater_id.'[]" id="rate5_'.$rater_id.'" />Excellent</label>';
echo '<label for="rate4_'.$rater_id.'"><input type="radio" value="4" name="rating_'.$rater_id.'[]" id="rate4_'.$rater_id.'" />Very Good</label>';
echo '<label for="rate3_'.$rater_id.'"><input type="radio" value="3" name="rating_'.$rater_id.'[]" id="rate3_'.$rater_id.'" />Good</label>';
echo '<label for="rate2_'.$rater_id.'"><input type="radio" value="2" name="rating_'.$rater_id.'[]" id="rate2_'.$rater_id.'" />Fair</label>';
echo '<label for="rate1_'.$rater_id.'"><input type="radio" value="1" name="rating_'.$rater_id.'[]" id="rate1_'.$rater_id.'" />Poor</label>';

And I changed it to this for use with a drop down menU:

echo '<select name="select">
            <label for="rate5_'.$rater_id.'"><option value="5" name="rating_'.$rater_id.'[]" id="rate5_'.$rater_id.'">Excellent</option></label>
            <label for="rate4_'.$rater_id.'"><option value="4" name="rating_'.$rater_id.'[]" id="rate4_'.$rater_id.'">Very Good</option></label>
           <label for="rate3_'.$rater_id.'"><option value="3" name="rating_'.$rater_id.'[]" id="rate3_'.$rater_id.'">Good</option></label>
            <label for="rate2_'.$rater_id.'"><option value="2" name="rating_'.$rater_id.'[]" id="rate2_'.$rater_id.'">Fair</option></label>
            <label for="rate1_'.$rater_id.'"><option value="1" name="rating_'.$rater_id.'[]" id="rate1_'.$rater_id.'">Poor</option></label>
          </select>';

Something is not working, and unfortunately I can't see what

thanks

Link to comment
Share on other sites

You should not have those label tags there. In addition, the name goes to the <select> tag and not the <option> tags (and you probably don't need the IDs either, since you don't have the labels). This might work slightly better:

 

echo '<select name="rating_'.$rater_id.'[]">
<option value="5">Excellent</option>
<option value="4">Very Good</option>
<option value="3">Good</option>
<option value="2">Fair</option>
<option value="1">Poor</option>
</select>'

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.