i have a drop down menu..i want to auto load selected value when page is open.but i do not know how to do it.anyone can help?
<select name="num" onchange="this.form.submit()">
<option value="25" selected>25</option>
<option value="50">50</option>
<option value="75">75</option>
<option value="100">100</option>
</select>
for example, when i go to that page, the page auto display 25 record to me.
Your page must be named with .php extension and you have to have access to that result:
<?php
//let's assume you take selected value from $_POST
if(isset($_POST['num']){
$selected_option = $_POST['num'];
}else{
$selected_option = '';
}
$options = array(25,50,75,100);
?>
<form id="myForm" method="post" action = "">
<select name="num" onchange="document.getElementById('myForm').submit()">
<?php
foreach($options as $v){
if($v == $selected_option){
$selected = 'selected = "selected"';
}else{
$selected = '';
}
echo "<option value='$v' $selected>$v</option>";
}
?>
</select>
</form>