gpt4 book ai didi

javascript - js 似乎无法找到我的表单

转载 作者:行者123 更新时间:2023-12-02 20:47:04 26 4
gpt4 key购买 nike

<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>

在我的脚本中,我有:

var r=document.forms.pollvoteform1.poll_option1;

但我收到错误:

document.forms.pollvoteform1 未定义我不明白为什么。因为 pollvoteform1 和 poll_option_1 都在那里。

//更新:完整的js代码

    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");
}
}

最佳答案

它要么

var r=document.forms['pollvoteform1'].poll_option1;

或者如果这不起作用

var r=document.forms[0].poll_option1;

关于javascript - js 似乎无法找到我的表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/915355/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com