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
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; }

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.