gpt4 book ai didi

javascript - 动态添加的表单元素在 IE 9 中不会被发布

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

我有一个用于进行测试的表格。用户输入问题并提供问题类型和答案选项并保存问题。问题在于,当用户编写一个选项并单击“添加到选项”按钮时,选项文本框的内容将添加到 DOM 以显示为问题的答案。这一切都运行良好,直到 IE9 出现为止。
当用户单击“添加到选项”按钮时,选项将显示在 DOM 中,但该值不会在 IE9 中发布。
将Option添加到DOM的函数是

    var tbl = document.getElementById('tbl');
var lastRow = tbl.rows.length;
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
arr[ind] = iteration;

var cellLeft1 = row.insertCell(0);
var cellLeft2 = row.insertCell(1);
var cellLeft3 = row.insertCell(2);
if(document.crt_question.test_ans_view[0].checked)
{
if(document.crt_question.test_ans_choice.value=="0") // MCQ with Single Answer (Radio Buttons)
{

var op_val=document.crt_question.test_answer.value;
var words=op_val.split("");
op_val='';

for(i=0;i<words.length;i++)
{
op_val = op_val + words[i].replace('"',"'");
}
cellLeft1.innerHTML = '<div id="button_div'+ind+'" class="dom_"><input type="radio" name="button_'+ind+'" id="button_'+ind+'" value="'+ind+'" ></div>';
cellLeft2.innerHTML = '|<input type="image" src="../../_images/view_del.gif" onclick="return removeRowFromTable('+ ind +')" />|';

var newOption = document.createElement("input");
newOption.name = "test_answer"+ind+"";
newOption.type = "hidden";
newOption.value = op_val;

var newOption2 = document.createElement("input");
newOption2.name = "view_option"+ind+"";
newOption2.type = "text";
newOption2.value = op_val;
cellLeft3.appendChild(newOption);
cellLeft3.appendChild(newOption2);
ind++;
remove++;
}
}

添加选项的表是

  <table id="tbl" border="0"  style="padding-left:70px;">
<tr>
<td align="left"></td>
<td align="left" ></td>
<td align="left"></td>
</tr>
</table>

在顶部函数中,当提交表单时,我没有获得隐藏值或输入类型文本字段的值。这适用于 FF 和 IE8。任何人都可以得到这个东西吗?

注意:此代码在通过 IFRAME 包含的文件中运行。

最佳答案

该问题完全是由于 IE9 标准造成的。在兼容性 View 中,错误已被删除。因此,如果有人遇到此类问题,只需在文档的头部添加以下行:<meta http-equiv="X-UA-Compatible" content="IE=8" />

关于javascript - 动态添加的表单元素在 IE 9 中不会被发布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7344033/

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