Php Javascript:发布到新窗口
我无法通过post从以下功能提交一些隐藏的表单数据:Php Javascript:发布到新窗口,php,javascript,post,Php,Javascript,Post,我无法通过post从以下功能提交一些隐藏的表单数据: function displayCertificate() { window.open("../mailer.php","certificate","width=500,height=400,status=1") } var sHTML = ""; sHTML += '<FORM id="quizResults" method="POST" action="/articulate/mailer.php" enctype="te
function displayCertificate()
{
window.open("../mailer.php","certificate","width=500,height=400,status=1")
}
var sHTML = "";
sHTML += '<FORM id="quizResults" method="POST" action="/articulate/mailer.php" enctype="text/plain" target="certificate" onSubmit="displayCertificate()">';
sHTML += '<INPUT TYPE="hidden" NAME="name" VALUE=\'' + g_arrResults[0].strStudentResponse + '\'>';
sHTML += '<INPUT TYPE="hidden" NAME="email" VALUE=\'' + g_arrResults[1].strStudentResponse + '\'>';
sHTML += '<br><input type="submit"><br>';
sHTML += '</FORM>';
alert(g_arrResults[0].strStudentResponse);
document.getElementById("divEmail").innerHTML = sHTML;
document.getElementById("quizResults").submit();
以下是数组中第一个对象的示例:
bFound
false
dtmFinished
Date {Thu Nov 17 2011 12:54:29 GMT+0000 (GMT Standard Time)}
nPoints
"0"
nQuestionNum
1
strCorrectResponse
" "
strInteractionId
"I4e28818f-4014-418c-a6e4-863679014098"
strLatency
"1862"
strObjectiveId
"I4e28818f-4014-418c-a6e4-863679014098"
strQuestion
" "
strResult
"neutral"
strStudentResponse
"Peter Rabbit"
strType
"fillin"
删除窗口。打开代码并尝试将target=“\u blank”添加到表单:
<FORM target="_blank" id="quizResults" method="POST" ...>
因为您试图在提交页面之前访问页面mailer.php 从表单标记中删除onsubmit()方法
然后尝试它将起作用您需要将表单插入弹出窗口文档,然后自动提交:
function displayCertificate()
{
var win = window.open("","certificate","width=500,height=400,status=1");
win.document.open();
win.document.write('<FORM id="quizResults" method="POST" action="/articulate/mailer.php" enctype="text/plain" target="certificate" onSubmit="displayCertificate()">');
win.document.write('<INPUT TYPE="hidden" NAME="name" VALUE=\'' + g_arrResults[0].strStudentResponse + '\'>');
win.document.write('<INPUT TYPE="hidden" NAME="email" VALUE=\'' + g_arrResults[1].strStudentResponse + '\'>');
win.document.write('<br><input type="submit"><br>');
win.document.write('</FORM>');
win.document.close();
win.document.getElementById('quizResults').submit();
}
函数显示证书()
{
var win=window.open(“,”证书“,”宽度=500,高度=400,状态=1”);
win.document.open();
win.document.write(“”);
win.document.write(“”);
win.document.write(“”);
win.document.write(“
”);
win.document.write(“”);
win.document.close();
win.document.getElementById('quizResults').submit();
}
(为了举例,使用谷歌)。什么是var\u转储($\u POST);给你什么?好像是服务器端的东西。@WillemMulder告诉我没有POST数据:
array(0){}
你能做一个console.log(g_arresults)吗;用JavaScript?我想看看你在发送什么(如果有实际数据)。@alessioalex添加到questionforms可以提交到目标“_blank”。在窗口之前已经尝试过。打开,相同的结果无效。你是否也删除了其他目标属性(target=“certificate”)从表单?中删除enctype属性,并从表单中删除已测试和works@George然后你做了一些事情来阻止它,mlitn发布的内容是100%正确的。
<FORM target="_blank" id="quizResults" method="POST" ...>
function displayCertificate()
{
var win = window.open("","certificate","width=500,height=400,status=1");
win.document.open();
win.document.write('<FORM id="quizResults" method="POST" action="/articulate/mailer.php" enctype="text/plain" target="certificate" onSubmit="displayCertificate()">');
win.document.write('<INPUT TYPE="hidden" NAME="name" VALUE=\'' + g_arrResults[0].strStudentResponse + '\'>');
win.document.write('<INPUT TYPE="hidden" NAME="email" VALUE=\'' + g_arrResults[1].strStudentResponse + '\'>');
win.document.write('<br><input type="submit"><br>');
win.document.write('</FORM>');
win.document.close();
win.document.getElementById('quizResults').submit();
}