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
Vertical And Horizontal Align Of Image
I have a placeholder (under construction) site which holds …
Set CSS Width To 100% + Right Border Is Missing?
I set a div's width to 100% of the window. When I apply…
Z-index 'breaks' Slideshow Click Buttons
I've got this problem where my navbar goes behind my sl…
IE11 Textarea Loses Focus If Another Textarea Is Disabled
In this fiddle, using ie11 with open Console, input somethi…
Playing Mp3 Shoutcast Streams With Html5 Audio In Firefox?
I'm trying to play mp3 shoutcast stream radio stations …
HTML5 "required" Validation Is Not Showing Error Message In Mozilla Firefox
This is a peculiar problem but is happening only in a parti…
How To Get Highest Input Field Value In Javascript
I want to get highest value of this field. How I can do thi…
SVG Animation And Firefox
I'm struggle with SVG animation drawing, which is work …
Homepage Slow To Load
When I go to the homepage of my website after clearing my c…
How To Add Vertical Sub-menu To Horizontal Menu Using Css And Html?
I want to add a vertical sub-menu to my horizontal menu. I …
December 2024
(1)
November 2024
(39)
October 2024
(66)
September 2024
(21)
August 2024
(353)
July 2024
(334)
June 2024
(673)
May 2024
(1291)
April 2024
(771)
March 2024
(1533)
February 2024
(1707)
January 2024
(1401)
December 2023
(1396)
November 2023
(420)
October 2023
(651)
September 2023
(283)
August 2023
(323)
July 2023
(288)
June 2023
(360)
May 2023
(225)
April 2023
(144)
March 2023
(139)
February 2023
(167)
January 2023
(258)
December 2022
(122)
November 2022
(232)
October 2022
(604)
September 2022
(161)
August 2022
(285)
July 2022
(92)
Menu Halaman Statis
Beranda
© 2022 - Html5 Learning