<div class="poll">
<h1>Poll</h1>
<form name="pollvoteform1" method="post" xxaction="/plugins/content_types/poll/poll.php">
<p class="tekstaanmelden"><b>Het regent </b></p>
<input type="hidden" name="poll" value="1">
<input type="hidden" name="cmd" value="">
<div class="pollOption"><input type="radio" class="stelling" name="poll_option1" value="1"></div><div class="pollOptionText">Eens</div><br clear="all"><div class="pollOption"><input type="radio" class="stelling" name="poll_option1" value="2"></div><div class="pollOptionText">Oneens</div><br clear="all"><div class="pollOption"><input type="radio" class="stelling" name="poll_option1" value="3"></div><div class="pollOptionText">Waar</div><br clear="all"><div class="pollOption"><input type="radio" class="stelling" name="poll_option1" value="4"></div><div class="pollOptionText">Niet waar</div><br clear="all">
<input type="button" name="bt_submit" class="pollButtonNormal" onmouseover="this.className='pollButtonHigh';" onmouseout="this.className='pollButtonNormal';" value="Stem" onclick="javascript:vote1();" style="padding-bottom: 3px; margin-top: 5px;">
<input type="button" name="bt_submit2" class="pollButtonNormal" onMouseOver="this.className='pollButtonHigh';" onMouseOut="this.className='pollButtonNormal';" value="Bekijk resultaten" onclick="javascript:viewResults1();" style="padding-bottom: 3px; margin-top: 5px; width:98px;">
</form>
</div>
<div style="display:none;width: 175px;">
<form><input type="button" name="bt_submit" class="pollButtonNormal" onmouseover="this.className='pollButtonHigh';" onmouseout="this.className='pollButtonNormal';" value="Resultaten" onclick="javascript:viewResults1();" style="padding-bottom: 3px; margin-top: 10px; "></form>
</div>
In my script I have:
var r=document.forms.pollvoteform1.poll_option1;
But I get the error:
document.forms.pollvoteform1 is undefined And I don't understand why. Since the pollvoteform1 and the poll_option_1 are both there.
//update: the full js code
function vote() {
var r=document.forms.pollvoteform1.poll_option1;
var voted=false;
if (r.value!=null && r.checked){
voted=true;
} else {
for (i=0;i<r.length;i++){
if (r[i].checked) {
voted=true;
break;
}
}}
if (voted) {
document.forms.pollvoteform1.submit();
} else {
alert("you didn't make a choice yet");
}
}