[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 333
  • Last Modified:

onChange value

Got a simple list that when the options change it fires an function ajaxcall.

Is it possible to put the value of the change and other lists in?

So for example, current code is:-
<select name="select1" size="5" STYLE="width: 150px" onChange="ajaxcall('catSel2.php',ajaxCat1,'catSel2');">
<select name="select2" size="5" STYLE="width: 150px" onChange="ajaxcall('catSel2.php',ajaxCat1,'catSel2');">

Id like it to say something like:-
<select name="select1" size="5" STYLE="width: 150px" onChange="ajaxcall('catSel2.php?select1=' . select1.value . '&select2=' . select2.value . ',ajaxCat1,'catSel2');">

Any ideas?

Thank you
1 Solution
Try adding ids along with the names, then:

<select name="select1" id="select1" size="5" STYLE="width: 150px" onChange="ajaxcall('catSel2.php?select1=' + document.getElementById('select1').value + '&select2=' + document.getElementById('select2').value + ',ajaxCat1,'catSel2');">

There are other ways to do this, but this is clear enough.  Also, note that + is used for concatenation.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now