<style type="text/css">
#box { background-color:#FFFF99; border:thin solid #FF0000; width:70%; height:50px;}
#myformDiv { background-color:#FF9900; width:200px; height:70px;}
style>
<script type="text/javascript" src="firebug.js">
<script language="javascript" src="jquery-1.3.2.min.js">
<script language="javascript" src="jquery.corner.js">
<script language="javascript">
$(document).ready(function() { //Finish loading the entire page before processing any javascript
$('#myformDiv').corner(); // Rounds corners of selected div. In this example "myformDiv"
$("#subBut").click(function(event) {
var formContent = $("#form1").serialize();
$("#box").load('myserv.php',formContent);
});
});
script>
<div id="myformDiv">
<form name="form1" id="form1" method="post" action="">
<label>Name
<input type="text" name="textfield" id="textfield">
label>
<input type="button" name="subBut" id="subBut" value="Submit">
form>
div>
<br />
<div id="box">Ajax calldiv>
<style type="text/css">
#box { background-color:#FFFF99; border:thin solid #FF0000; width:70%; height:50px;}
#myformDiv { background-color:#FF9900; width:300px; height:170px;}
.error-highlight {border: 2px solid #f00;}
.errMissFld {color: #f00;}
style>
<script type="text/javascript" src="firebug.js">
<script language="javascript" src="jquery-1.3.2.min.js">
<script language="javascript" src="jquery.corner.js">
<script language="javascript" src="jquery.validation.js">
<script language="javascript">
$(document).ready(function() { //Finish loading the entire page before processing any javascript
$('#myformDiv').corner(); // Rounds corners of selected div. In this example "myformDiv"
$('#form1').bind('submit', function() {
tst= $(this).validation();
if(tst==false){return tst;}
var formContent = $("#form1").serialize();
$("#box").load('myserv.php',formContent);
return false;
});
});
script>
<div id="myformDiv">
<form name="form1" id="form1" method="post" action="">
<p class="required-field">
<label>Name
<input type="text" name="name" id="name">
label>
p>
<p class="required-field">
<label>Name
<input type="text" name="address" id="address">
label>
p>
<input type="submit" name="subBut" id="subBut" value="Submit">
form>
<div class="errMissFld">
div>
div>
<br />
<div id="box">Ajax calldiv>
请注意,这并不是原始的jQuery.validation插件。已被我修改以执行此方式。
打开myserv.php并将所有代码替换为以下内容
echo "hello world! My name is " . $_GET['name'];
?>
//假设我有许多可选的电台。我将使用这个列表。
$vals=array();
for ($i = 1; $i <= 6; $i++) {
$vals[$i]['id']=$i;
$vals[$i]['name']='Radio Station Name:'.$i;
}
?>
这是我的首选电台
foreach ($vals as $val) { // 创建一个电台列表
?> - echo $val['id']; ?>">echo $val['name']; ?>
} ?>
Ajax调用
如果 $_GET['action']=="radio"){
echo "我偏好的单选按钮是:".$_GET['link'];
} else {
echo "hello world! 我的名字是 " . $_GET['name'];
}
?>
|