Okay, after messing around with this for numerous days, and reading through countless help pages, it's time to ask for help. This code has no problems. Whatever text I enter into the form will show in the popup box. Good.
<script>
function yesorno1(){
var form = document.getElementById('escalation');
if(form.value != "")
alert("You entered: " + form.value)
else
alert("There is some problem")
}
</script>
<input type='text' id='escalation' />
<input type='button' onclick='yesorno1()' value='Submit' />
If I change the HTML from a form to a radio button or drop-down selector, the popup box will always only display the value from the first radio or first drop down option in the list. For example, in the below code, the first radio option is "yes" and the second radio option is "no." Regardless if I radio yes or no, the popup box always gives "yes."
<script>
function yesorno2(){
var rad = document.getElementById('escalation2');
if(rad.value != "")
alert("You entered: " + rad.value)
else
alert("There is some problem")
}
</script>
Is this an escalation?<br>
<input type='radio' id='escalation2' value='yes'> Yes<br>
<input type='radio' id='escalation2' value='no'> No<br><br>
<input type='button' onclick='yesorno2()' value='Submit' />
Does anyone know of a way to code this so that radio yes will give popup message "yes" and radio no will give popup message no?