Retain drop down selected php
When you post a drop down input the resulting page drop down automatically moves to it selected value.PHP switch statement could be applied to solve this problem
Codes are displayed bellow
<?php $D=$_POST['D']; switch ($D) { case "Monday": $Mon="selected"; break; case "Tuesday": $Tue="selected"; break; case "Wednesday": $Wed="selected"; break; case "Thursday": $Thu="selected"; break; case "Friday": $Fri="selected"; break; case "Saturday": $Sat="selected"; break; case "Sunday": $Sun="selected"; break; } echo " <form method=post action=selected.php> <select name=D> <option value=Monday $Mon>Monday</option> <option value=Tuesday $Tue>Tuesday</option> <option value=Wednesday $Wed>Wednesday</option> <option value=Thursday $Thu>Thursday</option> <option value=Friday $Fri>Friday </option> <option value=Saturday $Sat>Saturday</option> <option value=Sunday $Sun>Sunday</option> </select> <input type=submit value=Submit> "; ?> |
No comments:
Post a Comment