Tuesday, March 15, 2011

To show selected dropdown value on php page submit

<select name="ddgrvgtm" id="ddgrvgtm" onchange="this.form.submit()">
<option <?php if ($_POST['ddgrvgtm'] == '--Select--' || $_POST['ddgrvgtm'] == '') print 'selected '; ?> value="--Select--">--Select--</option>
<option <?php if ($_POST['ddgrvgtm'] == 'My Name is Gaurav') print 'selected '; ?> value="My Name is Gaurav">My Name is Gaurav </option>
<option <?php if ($_POST['ddgrvgtm'] == 'I am from Varanasi') print 'selected '; ?> value="I am from Varanasi">I am from Varanasi</option>
<option <?php if ($_POST['ddgrvgtm'] == 'I have done graduation from Nagpur') print 'selected '; ?> value="I have done graduation from Nagpur">I have done graduation from Nagpur</option>
<option <?php if ($_POST['ddgrvgtm'] == 'Currently Working in Bangalore') print 'selected '; ?> value="Currently Working in Bangalore">Currently Working in Bangalore</option>
<option <?php if ($_POST['ddgrvgtm'] == 'I support AC Milan Fc') print 'selected '; ?> value="I support AC Milan Fc">I support AC Milan Fc</option>
<option <?php if ($_POST['ddgrvgtm'] == 'I donate all blog money in poor child study') print 'selected '; ?> value="I donate all blog money in poor child study">I donate all blog money in poor child study</option>
<option <?php if ($_POST['ddgrvgtm'] == 'Thank for reading this post') print 'selected '; ?> value="Thank for reading this post">Thank for reading this post</option>
</select>

No comments:

Post a Comment