persist dropdown menu values after submit
if you want to keep your drop down menu values after submitting, you can use javascript to persist these values.
document.getElementById('foo').value = "<?php echo htmlentities($_GET['foo'], ENT_QUOTES);?>";
Written by teknonono
Related protips
3 Responses

This is open to XSS...
GET and POST vars should be escaped with htmlentities() as a minimum.
over 1 year ago
·

hi mattinahat99, thanks for your reminding!
over 1 year ago
·

This Javascript lib that does this as well. http://garlicjs.org/
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Related Tags
#javascript
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#