我的 JavaScript 代码是
function addTaskSkill(form) {
var at = form.all_skill.length -1;
var td = form.task_skill.length -1;
var tasks = "x";
if(td>=0 && form.task_skill.options[0].value==skll_id){
form.task_skill.options[0] = null;
td = form.task_skill.length -1;
}
for (td; td > -1; td--) {
tasks = tasks + "," + form.task_skill.options[td].value + ","
}
for (at; at > -1; at--) {
if (form.all_skill.options[at].selected && tasks.indexOf("," + form.all_skill.options[at].value + ",") == -1) {
t = form.task_skill.length
opt = new Option(form.all_skill.options[at].text, form.all_skill.options[at].value);
form.task_skill.options[t] = opt
}
}
//checkForTaskSkill(form.task_skill);
}
function removeTaskSkill(form) {
td = form.task_skill.length -1;
for (td; td > -1; td--) {
if (form.task_skill.options[td].selected) {
form.task_skill.options[td] = null;
}
}
}
我的调用功能是
<form action="#" method="post" name="detailFrm">
<table>
<tr>
<td>
<select name="all_skill" size="10" class="span5" multiple="multiple" >
<option value="30">Apache</option>
<option value="31">Microsoft IIS</option>
<option value="32">Tomcat</option>
<option value="34">JBoss</option>
<option value="35">BEA WebLogic</option>
</select>
</td>
<td><input type="button" class="btn" value=">" onclick="javascript:addTaskSkill(document.detailFrm)" />
<br><br><input type="button" class="btn" value="<"
onclick="javascript:removeTaskSkill(document.detailFrm)" /></td>
<td>
<select name="task_skill" class="span5" size="10" multiple="multiple"> </select>
</td>
</tr>
</table>
</form>
在这里,我从一个选择框中选择一些选项,单击>>
它应该推送到下一个选择框。我得到的错误是
TypeError: form.all_skill is undefined
[Break On This Error]
var at = form.all_skill.length -1;
我没有得到解决方案。请在此处提供帮助以获得解决方案。我正在尝试制作一个列表框交换器。
提前致谢。