Jump to content

Form Radio Buttons


Guest CFCAgency
 Share

Recommended Posts

Guest CFCAgency

I have a Feedback Form that I have created where the user has the option of choosing between two radio buttons. One radio button is to submit the feedback “Anonymously”, and The other radio button is if the person wants to include their name.The code for that selection currently reads: <input type="radio" class="radio" id="feedback" name="Name" value="Anonymous" /> Anonymous <input type="radio" class="radio" id="feedback" name="Name" /> <input type="text" name="Name" size="30">Here’s my problem (you may have already seen it).When they choose the button to submit their name and they enter their name, it submits just fine.When they choose the button to submit “Anonymously” it submits an empty field; in other words the “value” of “Anonymous” does not submit.What am I missing? Any help is greatly appreciated.

Link to comment
Share on other sites

First of all your two radio buttons have the same ID. ID's all need to be unique. Second, I would change the name attribute of your radio buttons to something like "Type." All three of your elements currently have the same name, which might cause problems.Anyway, change the name of your radio buttons (it can be the same for both) and add a value to both. Then in the script you submit to you can determine which one is checked (ie. Check the POST variable for the value) and if the "Name" radio is checked (not the "Anonymous" radio) get the value from the text box. If the "Anonymous" radio is checked you can do whatever it is you need to do for that.

Edited by jkloth
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...