gpt4 book ai didi

php 中的 JavaScript 问题

转载 作者:行者123 更新时间:2023-11-28 10:34:29 24 4
gpt4 key购买 nike

波纹管是我的 php 代码。

    <div class="poller">

<div class="poller_question" id="poller_question2">
<p class="pollerTitle">Would you join a Community Action Committee?</p>
<p class="pollerOption"><input type="radio" value="6" name="vote[2]" id="pollerOption6">
<label for="pollerOption6" id="optionLabel6">Yes</label></p><p class="pollerOption">
<input type="radio" value="7" name="vote[2]" id="pollerOption7"><label for="pollerOption7"
id="optionLabel7">Maybe</label></p><p class="pollerOption"><input type="radio" value="8"
name="vote[2]" id="pollerOption8"><label for="pollerOption8" id="optionLabel8">No</label></p>
<a href="#" onclick="castMyVote(2,document.forms[0])"><imgsrc="images/vote_button.gif" border="0"></a>

</div>
<div class="poller_waitMessage" id="poller_waitMessage2">
Getting poll results. Please wait...
</div>
<div class="poller_results" id="poller_results2">
<!-- This div will be filled from Ajax, so leave it empty --></div>
</div>

波纹管是我的 JavaScript 代码

function castMyVote(pollId,formObj)
{
var elements = formObj.elements['vote[' + pollId + ']'];
var optionId = false;
for(var no=0;no<elements.length;no++){
if(elements[no].checked)optionId = elements[no].value;
}
Poller_Set_Cookie('dhtmlgoodies_poller_' + pollId,'1',6000000);
if(optionId){

var ajaxIndex = ajaxObjects.length;
ajaxObjects[ajaxIndex] = new sack();
ajaxObjects[ajaxIndex].requestFile = serverSideFile + '?pollId=' + pollId + '&optionId=' + optionId;
prepareForPollResults(pollId);
ajaxObjects[ajaxIndex].onCompletion = function(){ showVoteResults(pollId,ajaxIndex); }; // Specify function that will be executed after file has been found
ajaxObjects[ajaxIndex].runAJAX(); // Execute AJAX function

}
}

在 php 中,我调用了一个名为“castMyVote”的 javascript 方法。该 javascript 是

var elements = formObj.elements['vote[' + pollId + ']'];

制造问题?为什么?如何解决?var元素没有值

最佳答案

尝试

var elements = document.getElementsByName("vote["+pollId+"]");

关于php 中的 JavaScript 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2011108/

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