在单页中使用ajax和php上传多个表单数据
my doubt is about what if i have
我的疑问是关于我有什么
these div tags are hidden using transition effects using a jquery i want to get results of div 1 2 3 in results
使用jquery使用过渡效果隐藏这些div标签我想在结果中获得div 1 2 3的结果
1 div
<div id="1">
</div>
2 div
<div id="2">
</div>
3 div
<div id="3">
</div>
<input type="submit" name="first-sudmit" value="NEXT" onclick="result(this.value)" />
</div>
<div id="result">
result
</div>
in js:
<script type="text/javascript">
function showResult()
{
alert("dfadsfdasf");
xmlhttp.open("GET","result.php?q="+str,true);
xmlhttp.send();
}
</script>
and i even tried serialisation tooo..... not running the php script
我甚至尝试序列化太...不运行PHP脚本
like
js:
<script type="text/javascript">
function showFormData(oForm) {
var msg = "The data that you entered for the form with 'name' attribute='" + oForm.name + "': \n";
submitHandler: function(form) {
// do other stuff for a valid form
$.post('result.php', $("#submit_drop,#submit_radio,#submit_check,#submit_text,#submit_drag_text,#submit_drag_img").serialize(), function(data) {
$('#results').html(data);
});
alert(msg);
}
</script>
php:
//page1 process
if(!ekpty($_POST['first-submit']))
{
$first1=$_POST['drop1'];
$first2=$_POST['drop2'];
$first3=$_POST['drop3'];
$first4=$_POST['drop4'];
$first5=$_POST['drop5'];
for(i=0;i<=4;i++)
{
$sql="INSERT INTO $score1(correct)VALUES('$first[i]')";
}
}
else
{
print '<script type="text/javascript">';
print 'alert("page 1 no answer is attempted")';
print '</script>';
}
//output resu;ts
$sql="SELECT count(chkpt) from score1 where chkpt='1'";
echo $sql;
so now how to get the results of those forms in last result div tag.......
所以现在如何在最后的结果div标签中获得这些表单的结果.......
please some answer this.......
请一些回答这个.......
1 个解决方案
#1
0
Your question is a bit difficult to read, but if I understand what you're asking I believe your serialization code would work, however I believe you need to use the ID of the form that contains the elements you wish to serialize. So:
您的问题有点难以阅读,但如果我理解您的要求,我相信您的序列化代码会起作用,但我相信您需要使用包含您希望序列化的元素的表单的ID。所以:
1 div
<div id="1">
<form id="firstFormToSubmit">......</form>
</div>
2 div
<div id="2">
<form id="secondFormToSubmit">......</form>
</div>
3 div
<div id="3">
<form id="thirdFormToSubmit">......</form>
</div>
<input type="submit" name="first-sudmit" value="NEXT" onclick="result(this.value)" />
</div>
<div id="result">
result
</div>
And then to handle these forms:
然后处理这些形式:
submitHandler: function(form) {
// do other stuff for a valid form
$.post('result.php', $("#firstFormToSubmit").serialize(), function(data) {
$('#results').html(data);
});
更多相关文章
- 阻止用户在表单字段中输入
- script标签写在哪里好?
- 从动态生成的音频标签中收听audio.ended
- 点击a标签,返回上一页
- JS实现60s倒计时(亲测有效),及span标签如何使用和禁用onclick事件
- FusionCharts的Line.swf做法,我想出现2条图形线,怎么设置graph标签
- 无法在JQuery中查找表单输入
- 如何在chart.js中为饼图添加标签
- 用于转换单位的HTML和JavaScript表单