0
<form method="POST" action="editprofile.htm" name="admintypeForm">
    <p><label class="left-col">Username:</label><input type="text" name="username" required value="${admindet.username}" placeholder=""></p>
    <p><label class="left-col">First Name:</label><input type="text" name="firstname"value="${admindet.firstName}" placeholder=""></p>
    <p><label class="left-col">Last Name:</label><input type="text" name="lastname"value="${admindet.lastName}" placeholder=""></p>
    <input type="hidden" name="password"value="${admindet.password}" placeholder="">
    <p><label class="left-col">Admin Type:</label><select name="admintype"><option value="administrator">Administrator</option><option value="moderator">Moderator</option></select></p>

    <p class="text-center"><input type="submit" name="commit" value="Update" class="btn-green2 btn"></p>
 </form>

I have posted my code above.To find a solution,I referred to this link How to retain selected value in a dropdown list in the same jsp page? but the solution provided in the above mentioned link does not work in my case.

Community
  • 1
  • 1
Minm
  • 25
  • 1
  • 5
  • Can you use HTML5 web storage? – akshaykumar6 Jul 16 '14 at 06:16
  • When changes are made to the form you have to save the value somewhere. I would use serverside sessions. But HTML5 storage might be a fun approach :) – Medda86 Jul 16 '14 at 06:18
  • Alternatively change your POST to an AJAX request. – ioseph Jul 16 '14 at 06:31
  • I don't want to use ajax is there any other way. I have used the server side sessions but still the selected value of drop down is not being displayed on reloading the page.I am using the above code in update profile page so whenever someone changes the admin type on the page then the option selected by him should be visible in the drop down on page reload but the default value is being displayed on page reload. – Minm Jul 16 '14 at 06:54

0 Answers0