Hi all, I tried this a few different ways but I can't seem to get the desired effect in javascript using class tags on two radio button fields. However, if I make the radio button fields single line fields, then the code works. What am I doing wrong?
I have a radio button called Degree with these choices:
- Adjunct
- Senior
- Master
Radio button field called Level with these choices:
- Non-Term
- Terminal Degree
(values are NonTerm, and Terminal)
I have a single line field that has a pre-populated number in it and only shows up if a respective Level and Degree is selected (so for each combination, I have an amount). Class tag: adjNT, adjT, senNT, senT, masNT, masT
I have another single line field for Total which I would like to populate with appropriate number (example: adjNT) when Level (example: Adjunct) and Degree (example: Non-Term) have been chosen.
$(document).ready(function(){ $(".degree input, .level input").change(function(){ var degree = $(".degree input").val(); var level = $(".level input").val(); if (level == "Adjunct" && degree == "NonTerm"){ $(".total input").val($(".adjNT input").val()); } else if (level == "Adjunct" && degree == "Terminal") { $(".total input").val($(".adjT input").val()); } else if (level == "Senior" && degree == "Terminal") { $(".total input").val($(".senT input").val()); } else if (level == "Senior" && degree == "NonTerminal") { $(".total input").val($(".senNT input").val()); } else if (level == "Master" && degree == "Terminal") { $(".total input").val($(".masT input").val()); } else if (level == "Master" && degree == "NonTerminal") { $(".total input").val($(".massNT input").val()); } }); })
I could make a radio button populate a hidden single line field and then base my selections off of that, but I tried using javascript to populate a field based on radio button selection and it didn't work.
Thank you for your help, please let me know if I need to clarify something!