Last Updated: February 25, 2016
·
352
· teknonono

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);?>";

3 Responses
Add your response

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 ·