<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>
elements (could be div, etc) with a class of "required-field". Pleae note that this isn't the original jquery.validation plugin. It's been hacked by me to perform this way.
open myserv.php and replace all code with this:
echo "hello world! My name is " . $_GET['name'];
?>
//Pretend I have a lot of radio stations to choose from. I will use this for the list.
$vals=array();
for ($i = 1; $i <= 6; $i++) {
$vals[$i]['id']=$i;
$vals[$i]['name']='Name of Radio Station:'.$i;
}
?>
This is my prefered radio station
foreach ($vals as $val) { // Create a list of radio stations
?>
- echo $val['id']; ?>">echo $val['name']; ?>
} ?>
Ajax call
if ($_GET['action']=="radio"){
echo "My preferred radio is:".$_GET['link'];
} else {
echo "hello world! My name is " . $_GET['name'];
}
?>
|