我正在创建一个在javascript函数中提交的表单.我将函数绑定到select元素的onchange事件.事件在chrome和firefox中运行良好,我测试了它,它调用了函数.但问题是;虽然chrome提交表单,但firefox没有.能否请你帮忙?
谢谢.
function getStatementDetails()
{
var stmtSelect = document.getElementById("statementSelect");
var selectedId = stmtSelect.options[stmtSelect.selectedIndex].value;
var stmtForm = document.createElement("form");
stmtForm.setAttribute('method',"post");
stmtForm.setAttribute('action',"mymiles-mystatement");
var stmtId = document.createElement("input");
stmtId.setAttribute('type',"hidden");
stmtId.setAttribute('name',"statementID");
stmtId.setAttribute('id',"statementID");
stmtId.setAttribute('value',selectedId);
stmtForm.appendChild(stmtId);
stmtForm.submit();
};
选择输入:
编辑:
我已阅读建议的帖子并尝试过.还是行不通.
功能最新状态:
function getStatementDetails()
{
var stmtSelect = document.getElementById("statementSelect");
var selectedId = stmtSelect.options[stmtSelect.selectedIndex].value;
var stmtForm = document.createElement("form");
stmtForm.setAttribute('method',selectedId);
var stmtSbmt = document.createElement("input");
stmtSbmt.setAttribute('type',"submit");
stmtSbmt.setAttribute('name',"tryMe");
stmtSbmt.setAttribute('id',"tryMe");
stmtSbmt.setAttribute('value',"try submit");
stmtForm.appendChild(stmtId);
stmtForm.appendChild(stmtSbmt);
stmtForm.submit();
};
最佳答案
原文链接:https://www.f2er.com/html/426558.html