how to map two select variables?

I have two select variables -department (HR, IT, Finance) and departmentID (1,2,3)

Now if I select HR from department drop down then it should automatically prompt as “1” in departmentID in the form.

How do I do this?? where should I type my condition??

So based on the change in department you want the other field departmentID to be changed?

You would use Contingency fields if using Subscription Model, otherwise you have to write your own javascript onchange event to do this.

So add a onchange event to department and in the function change the value of departmentID, you could also add a onchange to the departmentID so that department changes as well.

I’ve added a deliberate mistake, see if you can spot it before asking… :slight_smile:

regards
Seán

The deliberate mistake is not that there is no need, you might have that need, but you didn’t say so.

The deliberate mistake is if you have an event on one item which changes another, which has a onchange event that changes the first one, it will trigger the onchange event again giving an infinate loop…

BAD! you have to disable the second onchange and then reapply it if doing both, but that is for another day.

Read here

http://www.w3schools.com/jsref/event_onchange.asp

Example here

http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onchange

regards

i am guessing there is no need to add an onchange event to the departmentID.

I have no knowledge on Java Script. My company wants me to learn this tool. I am learning daily something new about the tool…

So what could be the java script under this scenario? I searched online about onchange event. I understood but I am not able to execute. Can you help me on the scrip?