Jump to content

select form option auto select fix


jwk811

Recommended Posts

i have a select form. when they click a certain option a js function is used to change something. the problem is when the page is reloaded that option is automatically still selected even when i have another one auto selected. this makes it so the option that is supposed to cause a function is already selected and the function isnt done so it messes things up. how can i make it so i can change the default selected option or auto load a function if its going to be selected on refresh.

 

(im not sure how confusing that was or not)

Link to comment
https://forums.phpfreaks.com/topic/219267-select-form-option-auto-select-fix/
Share on other sites

From what I know, refreshing the page will cause form elements to return to their default values.

 

Have you tried attaching an onload event handler? Something along the lines of:

 

window.onload = function() {document.getElementById("select").selectedIndex = 0; }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.