I am building a select option dynamically. I am selecting from the select option, one value. (values for list come from php How can I pass that selected value to PHP?
Solution 1:
I think I see what your problem is. You're not setting a select option.
Try this:<?php$options = 'John';
?><formid="swimdata"method="POST"action="save.php"><inputtype="radio"style="font-size: 16px;font-weight: bolder"name="gender"class ="gender"value="boys">BOYS
<inputtype="radio"style="font-size: 16px;font-weight: bolder"name="gender"class ="gender"value="girls">GIRLS
<tableid="meetTable"style="width:auto"><tr><th>EVENT:</th><th>NAME:</th><th>LANE:</th><th>TIME:</th><th>PLACE:</th><th>SCORE 1:</th><th>SCORE 2:</th><th>PLACE:</th><th>TIME:</th><th>LANE:</th><th>NAME:</th></tr></table><selectid ="s1"name="swimopt"class="so"value=""><?phpfor($i=0;$i<10;$i++){
echo'<option value="user '.$i.'" >user '.$i.'</option>';
}
?></select><inputtype="submit"name="formSubmit"value="Submit" /><inputtype="hidden"name="action1"value="addSwimmer"id="action1"></form>CopySolution 2:
The select option must be wrapped with html tag <option> with a value attribute, which will be posted if it is selected.
According to your given code you are not generating options for a select. So try something like this:if ($result->num_rows > 0) {
$options= '';
// output data of each row while($row = $result->fetch_assoc()) {
$options .= "<option value=\"". $row["swimmer_id"] ."\">" . $row["first_name"]. " " . $row["last_name"]. " - " . $row["school_name"]. "</option>";
}
} else {
echo"0 results";
}
echo$options;
$conn->close();
CopyNow if you $_POST it you will get the swimmer id
Share
Post a Comment
for "How To Pass The Selected Value In Dropdown (html) To Php"
Top Question
Firefox, Chrome, Safari Have Grey Background For Mp4 Html5 Video
Any video (that I can make) with a white background becomes…
Red Border Still Appears On Inputs After Resetting An HTML 5 Form Firefox
I have an HTML 5 form! Great, I'm excited! I decide to …
Svg Animation And Firefox
I'm struggle with SVG animation drawing, which is work …
Form To Iframe Submission - How Do You Reset The Form After File Upload?
I have a form that submits the results to an iframe. The su…
How To Hide/show Tabs Using Jquery
I have four tabs.On loading only the first tab is opened an…
How To Save Html5 Geolocation Data To Python Django Admin?
Is it possible to save the javascript html5 geolocation lat…
How To Limit The Html Table Records In Each Page
I am populating a table in my jsp which has more than 20 re…
How To Display A Python String As Html In Jupyter Notebook
In IPython notebook, I used to be able to display a python …
How To Add Placeholder Field?
I've been trying to add placeholder in input type='…
Bounce Animation On A Scaled Object
What is the best way to have an object scale and then perfo…