I have a buttons named 'button1' and one Listmenu named listmenu1. All those button and Listmenu are in one form named form1
<?php
echo "<input type='submit' name='button1' id='button1' value='Go' />"; // button1
echo "<select name="listmenu1" id="listmenu1">
<option>a</option>
<option>b</option>
<option>c</option>
</select>"; .// listmenu1
if (isset($_POST['button1'])) // when user click on button1, button
{
$value=$_POST['listmenu1']; // get the selected value from listmenu1.assume that I selected b from listmenu1'.
}
?>
After click on the button1 I want to remaining the selected value of listmenu1.
If user select b from listmenu1 and click on button1,then listmenu1 should be selected as b.
How can i do this..?
thanking u all.....
How can i remember the selected value from listmenu?
Moderator: General Moderators
Re: How can i remember the selected value from listmenu?
Hello,
Please put the following code and check it,
<?php
echo "<form name='form1' action='' method='post'>";
echo "<input type='submit' name='button1' id='button1' value='Go' />"; // button1
echo "<select name='listmenu1' id='listmenu1'>
<option>a</option>
<option>b</option>
<option>c</option>
</select></form>"; // listmenu1
if (isset($_POST['button1'])) // when user click on button1, button
{
$value=$_POST['listmenu1']; // get the selected value from listmenu1.assume that I selected b from listmenu1'.
echo $value;// print the selected value from listmenu1
}
?>
Thanks & Regards
Please put the following code and check it,
<?php
echo "<form name='form1' action='' method='post'>";
echo "<input type='submit' name='button1' id='button1' value='Go' />"; // button1
echo "<select name='listmenu1' id='listmenu1'>
<option>a</option>
<option>b</option>
<option>c</option>
</select></form>"; // listmenu1
if (isset($_POST['button1'])) // when user click on button1, button
{
$value=$_POST['listmenu1']; // get the selected value from listmenu1.assume that I selected b from listmenu1'.
echo $value;// print the selected value from listmenu1
}
?>
Thanks & Regards
Re: How can i remember the selected value from listmenu?
You need to give your Select box values, like so.dilruk83 wrote:I have a buttons named 'button1' and one Listmenu named listmenu1. All those button and Listmenu are in one form named form1
<?php
echo "<input type='submit' name='button1' id='button1' value='Go' />"; // button1
echo "<select name="listmenu1" id="listmenu1">
<option>a</option>
<option>b</option>
<option>c</option>
</select>"; .// listmenu1
if (isset($_POST['button1'])) // when user click on button1, button
{
$value=$_POST['listmenu1']; // get the selected value from listmenu1.assume that I selected b from listmenu1'.
}
?>
After click on the button1 I want to remaining the selected value of listmenu1.
If user select b from listmenu1 and click on button1,then listmenu1 should be selected as b.
How can i do this..?
thanking u all.....
Code: Select all
<?php
echo "<input type='submit' name='button1' id='button1' value='Go' />"; // button1
echo "<select name="listmenu1" id="listmenu1">
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select>"; .// listmenu1
if (isset($_POST['button1'])) // when user click on button1, button
{
// Now $value is equal to whatever option was selected.
$value=$_POST['listmenu1']; // get the selected value from listmenu1.assume that I selected b from listmenu1'.
}
?>