Very simple PHP/HTML question for a Yes/No radio button and list.

How would I make this be a simple Installed/Not Installed radio button?  I have everything working right now with submitting from a text box but I don't want to give them the option of filling out a text box for this part.

<strong>Installed:</strong> <input type="text" name="Installed" value="<?php echo $Installed; ?>" />

Open in new window

Lastly, how would I make this a list of names instead of having them type in their names.  For example the managers would be Bob, Joe, and Jason.  How can I make this a list instead?

<strong>Manager:</strong> <input type="text" name="fmanager" value="<?php echo $fmanager; ?>" />

Open in new window

Thank you in advance
Who is Participating?
Mark BradyPrincipal Data EngineerCommented:
I would generate both controls (radio buttons and a select element) in php based on a query to the database. Obviously php would query their user account or where ever the data is stored to get their manager info.

You can have php build the radio buttons for you and they will be set according to what is in the database. Of course if you are hard coding the results then you would just do something like this.

<input type="select" id=manager" name="manager" onchange="update_manager()">
<option value="">Select a manager</option>
<option value="Bob">Bob</option>
<option value="Joe">Joe</option>
<option value="Jason">Jason</option>

Open in new window

The onchange part is in case you wanted to use ajax to update their manager when it gets changed.

Build the radio buttons in the same way with php so you get the current selection for that user from the database then as you go through the building of the element, add the word selected to the correct radio button.
Ray PaseurCommented:
Chris StanyonCommented:
The first line of Marks code should be:

<select id=manager" name="manager" onchange="update_manager()">

Open in new window

As for a radio, you'd use something like this:

<input type="radio" name="installed" value="yes" id="installedYes" checked> <label for="installedYes">Yes</label><br>
<input type="radio" name="installed" value="no" id="installedNo"> <label for="installedNo">No</label><br>

Open in new window

The label allows you to click on the Yes/No test to select the option and the check attribute means that value is checked by default.
Mark BradyPrincipal Data EngineerCommented:
Thanks Chris - My bad!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.