0
Activity Level<br>
        <input type = "radio" id="activitylevel" value="sedentary">Sedentary - Little or no exercise, desk job</option><br>
        <input type = "radio" id="activitylevel" value="lightly">Lightly active - Light exercise or sports 1-3 days/wk</option><br>
        <input type = "radio" id="activitylevel" value="moderately">Moderately active  Moderate exercise or sports 3-5 days/wk</option><br>
        <input type = "radio" id="activitylevel" value="very">Very active - Hard exercise or sports 6-7 days/wk</option><br>
        <input type = "radio" id="activitylevel" value="extremely">Extremely Active - Hard daily exercise or sports & physical labor job or 2 X day training, football camp, etc.</option><br>

Is there something wrong with this? I have spent an hour looking at the rest of my code figuring out why I can't pull the values been sent on this form, Im starting to think there is something wrong with this code. Any ideas? I have looked at examples online and they dont use 'id'?

Thanks, a very noobie question but any pointers or help is appreciated.

2
  • how do you get the values? Commented Aug 23, 2016 at 9:34
  • Replace ID with name Commented Aug 23, 2016 at 9:34

4 Answers 4

1

I think, you forgot to write name) names must be same for example name="radio_name" for all radio inputs. Write like below. But id in html mustn't be same. And why you are using i couldn't understand.

<input type="radio" name="activitylevel" id="activitylevel_1"  value="sedentary">Sedentary - Little or no exercise, desk job<br>
<input type = "radio" name="activitylevel" id="activitylevel_2" value="lightly">Lightly active - Light exercise or sports 1-3 days/wk<br>
<input type = "radio" name="activitylevel" id="activitylevel_3" value="moderately">Moderately active  Moderate exercise or sports 3-5 days/wk<br>
<input type = "radio" name="activitylevel" id="activitylevel_4" value="very">Very active - Hard exercise or sports 6-7 days/wk<br>
<input type = "radio" name="activitylevel" id="activitylevel_5" value="extremely">Extremely Active - Hard daily exercise or sports & physical labor job or 2 X day training, football camp, etc.<br>
0

You must define name for radio button

like this

<input type = "radio" id="activitylevel" name="activitylevel" value="sedentary">
2
  • Thank you so much.
    – PMG
    Commented Aug 23, 2016 at 9:44
  • if this answer is correct please accept this answer
    – ashkufaraz
    Commented Aug 23, 2016 at 10:23
0

You need to set each input fields name and then reference that name when trying to retrieve the values. For example:

<input type = "radio" name="activitylevel">Sedentary - Little or no exercise, desk job</option><br>

0

Inputs without names will not be submitted when form is submitted. So you need to add name to your inputs. Also there seems to be some syntactical mistakes. Corrected code looks like below:`

<input type = "radio" id="activitylevel1" value="sedentary" name="activitylevel">Sedentary - Little or no exercise, desk job</input>
        <input type = "radio" id="activitylevel2" value="lightly" name="activitylevel">Lightly active - Light exercise or sports 1-3 days/wk</input>
        <input type = "radio" id="activitylevel3" value="moderately" name="activitylevel">Moderately active  Moderate exercise or sports 3-5 days/wk</input>
        <input type = "radio" id="activitylevel4" value="very" name="activitylevel">Very active - Hard exercise or sports 6-7 days/wk</input>
        <input type = "radio" id="activitylevel5" value="extremely" name="activitylevel">Extremely Active - Hard daily exercise or sports & physical labor job or 2 X day training, football camp, etc.</input>`

Not the answer you're looking for? Browse other questions tagged or ask your own question.