KateMacwil Posted May 22, 2018 Share Posted May 22, 2018 HI I have 3 select drop downs on my page - Status, Type and Year. Each have a few options the user can select from. When the user selects an option, a textbox is updated with this value. Each select drop down has their own onchange function, Below is an example of the Year select drop down. <select class="custom-select" name="filter-year" onchange="FilterTendersYear(this);">> Here is my Javascript for this: function FilterTendersYear(selectObject) { var value = selectObject.value; document.getElementById("textbox-year").value = value; } How can I re-write this function so that it will work with all my 3 select boxes on the same page? Link to comment Share on other sites More sharing options...
justsomeguy Posted May 22, 2018 Share Posted May 22, 2018 Pass the function another value to tell it which field to update, or what the box is, or whatever information you need to make it general. You could also get the name of the select and use that. Link to comment Share on other sites More sharing options...
KateMacwil Posted May 22, 2018 Author Share Posted May 22, 2018 HI I tried passing the id and it didn't work Link to comment Share on other sites More sharing options...
justsomeguy Posted May 22, 2018 Share Posted May 22, 2018 Well, you probably didn't do it right then. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now