Jump to content
KateMacwil

onchange event question

Recommended Posts

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?

 

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×