0
我想使用Ajax后我的形式使用JQuery和Ajax发布形式
我想单选按钮来做到这一点(有没有提交布顿)
所以点击一个单选按钮将导致提交或进行后期形式
我的PHP页面需要知道的单选按钮的点击
是我的代码正确的名字吗?因为它不起作用,我不知道为什么?
<div id="Q1">
<form id="Question1" method='post'>
<br />
<P> The sky color is..
</P><img border="0" src="images/wonder.png" width="94" height="134"/><br /><br /><br />
<input type="radio" id="option1" name="answer[1]" value="correct!"/> blue
<br />
<input type="radio" id="option1" name="answer[1]" value="false!"/> red
<br />
<input type="radio" id="option1" name="answer[1]" value="false!"/> green
<br />
<input type="radio" id="option1" name="answer[1]" value="false!"/> white
<br />
<br /> </Form>
<!-- <p id="greatp" style="display: none;"> GREAT !!<br /><br /><br /><br /><br /><br /><br /></p> -->
<img border="0" src="images/welldone3.png" width="230" height="182" id="greatp" style="display: none;"/>
<!-- <p id="sorryp" style="display: none;"> Sorry !!<br /><br /><br /><br /><br /><br /><br /></p> -->
<img border="0" src="images/failed3.png" width="230" height="182" id="sorryp" style="display: none;"/>
<img src="images/false2.png"id="myImage1"style="display: none;"/>
<img src="images/correct2.png"id="myImage2"style="display: none;"/>
<!-- <input type= "submit" onclick="Next1()" value="Next"/> -->
<input type="image" src="images/next.png" name="image" width="80" height="30" onclick="Next1()">
</div>
jquery的鳕鱼:
<script>
$(document).ready(function(){
$("#option1").click(function() {
var answer= $("#option1").value;
var fff= $("#option1").name;
$.ajax({
type: "POST",
url: "page2.php",
data: fff,
success: function(){
if(answer=='correct!')
{
$('#greatp').show();
$('#myImage2').show();
$('#Question1').hide();
}
else
{
$('#sorryp').show();
$('#myImage1').show();
$('#Question1').hide();
}
}
});
return false;
});
});
</script>
谢谢你布拉德 数据呢? 如何给page2.php它需要的东西?在这种情况下如何给它的单选按钮的名称?我做的是对的吗? – user356719 2010-06-08 13:34:52
检查我的编辑... – brad 2010-06-08 20:12:09