Using Javascript to call on a value of a radio button question in HTML?

amy

New member
I am using the following javascript to create a value for a hidden variable. Participants will be viewing (and rating attractiveness for) four photos. Upon hitting "next image," I would like the new image to show up and the response from the radio button to measure attractiveness to be recorded into a hidden variable, defined as hotm, hotf, notm, and notf in form1. The name of the radio buttons for the question is "EA"

var temprating=document.form1.EA.value;

function nextimg(){
if (i != 5){
document.image1.src = images[i+1]

if (i == 1) {
document.form1.hotm.value=temprating;
}
else if (i == 2) {
document.form1.notf.value=temprating;
}
else if (i == 3) {
document.form1.notm.value=temprating;
}
else if (i == 4) {
document.form1.hotf.value=temprating;
}
i++
}
}

THE ISSUE: the variables in the hidden input tag in the form are being assigned a value, but that value is "Undefined" I assume this to mean that I am not defining my variable in my javascript correctly to link to the HTML form. Here is the question in form 1:

<p>How sexually attracted to this person are you?</p>
<p>

<input type="radio" name="EA" value="1" />
<label for="1">Extremely Unattracted</label>
<br />
<input type="radio" name="EA" value="2" />
<label for="2">Unattracted</label>
<br />
<input type="radio" name="EA" value="3" />
<label for="3">Slightly Unattracted</label>
<br />
<input type="radio" name="EA" value="4" />
<label for="4">Slightly Attracted</label>
<br />
<input type="radio" name="EA" value="5" />
<label for="5">Attracted</label>
<br />
<input type="radio" name="EA" value="6" />
<label for="6">Extremely Attracted</label>
<br />
<input type="radio" name="EA" value="." checked="checked" />
<label for="I prefer not to respond">I prefer not to respond</label>
</p>

<p><input type="button" value="Rate Attraction" onClick="nextimg(); return false;"/></p>

Please let me know if you need more information. Thank you!!!
 
Back
Top