A simple AJAX application of Dojo

Source: Internet
Author: User
Tags bind

The code is as follows:

Prpc.htm

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<meta http-equiv= "Content-type" content= "text/html; Charset=iso-8859-1 ">
<title>prpc test</title>
<script type= "Text/javascript" src= "Js/dojo/dojo.js" ></script>
<script type= "Text/javascript" >
Dojo.require ("dojo.io.*");
function Mysubmitprofile () {
Dojo.byid (' Btnaddprofile '). Disabled = ' disabled ';
Dojo.io.bind ({
URL: ' Serdojo?flag=profile ',
Handler:callback,
FormNode:dojo.byId (' main ')
});
}
function Mysubmitcountry () {
Dojo.byid (' btnaddcountry '). Disabled = ' disabled ';
Dojo.io.bind ({
URL: ' Serdojo?flag=country ',
Handler:callback,
FormNode:dojo.byId (' main ')
});
}
function CallBack (type, data, evt) {
if (data = = ' Profileyes ') {
Insertstrprofile ();
Dojo.byid (' Stateflag '). InnerHTML = data;
Dojo.byid (' Btnaddprofile '). Disabled = ';
else if (data = = ' Countryyes ') {
Insertstrcountry ();
Dojo.byid (' Stateflag '). InnerHTML = data;
Dojo.byid (' btnaddcountry '). Disabled = ';
}
}
function Insertstrprofile () {
var frm = Dojo.byid (' main ');
var name = Frm.name.value;
var sex;
var radio = document.getelementsbyname (' sex ');
for (var i = 0; i < radio.length i + +) {
if (frm.sex[i].checked) {
sex = Radio[i].value;
}
}
var age = Frm.age.value;
var address = Frm.address.value;
var txtname = document.createTextNode (name);
var txtsex = document.createtextnode (Sex);
var txtage = document.createTextNode (age);
var txtaddress = document.createTextNode (address);
var tdname = document.createelement ("TD");
var tdsex = document.createelement ("TD");
var tdage = document.createelement ("TD");
var tdaddress = document.createelement ("TD");
var tr = document.createelement ("tr");
Tdname.appendchild (txtname);
Tdsex.appendchild (Txtsex);
Tdage.appendchild (txtage);
Tdaddress.appendchild (txtaddress);
Tr.appendchild (Tdname);
Tr.appendchild (Tdsex);
Tr.appendchild (Tdage);
Tr.appendchild (tdaddress);
var parnode = document.getElementById ("Tbprofile");
Parnode.appendchild (TR);
}
function Insertstrcountry () {
var frm = Dojo.byid (' main ');
var country = Frm.country.value;
var company = Frm.company.value;
var website = frm.website.value;
var txtcountry = document.createTextNode (country);
var txtcompany = document.createTextNode (company);
var txtwebsite = document.createtextnode (website);
var tdcountry = document.createelement ("TD");
var tdcompany = document.createelement ("TD");
var tdwebsite = document.createelement ("TD");
var tr = document.createelement ("tr");
Tdcompany.appendchild (Txtcompany);
Tdcountry.appendchild (Txtcountry);
Tdwebsite.appendchild (Txtwebsite);
Tr.appendchild (Tdcompany);
Tr.appendchild (Tdcountry);
Tr.appendchild (Tdwebsite);
var parnode = document.getElementById ("Tbcountry");
Parnode.appendchild (TR);
}
</script>
<body>
<form id= "Main" >
<table width= "border=" 0 "align=" center "cellpadding=" 0 "cellspacing=" 0 "style=" border:1px dashed #000000; >
<tr>
&LT;TD valign= "Top" >
<table width= "100%" border= "0" cellspacing= "0" cellpadding= "3" >
<tr>
<td><table width= "80%" border= "1" align= "center" cellpadding= "1" cellspacing= "1" >
<tbody id= "Tbprofile" >
<tr>
<td>Name</td>
<td>Age</td>
<td>Sex</td>
<td>Address</td>
</tr>
</tbody>
</table></td>
</tr>
<tr>
<td><table width= "50%" border= "0" align= "center" cellpadding= "2" cellspacing= "1" bgcolor= "#CCCCCC" >
<tr>
&LT;TD width= "29%" bgcolor= "#EBEBEB" >Name:</td>
&LT;TD width= "71%" bgcolor= "#EBEBEB" ><input type= "text" name= "name"/></td>
</tr>
<tr>
&LT;TD bgcolor= "#EBEBEB" >Age:</td>
&LT;TD bgcolor= "#EBEBEB" ><input type= "text" name= "age"/></td>
</tr>
<tr>
&LT;TD bgcolor= "#EBEBEB" >Sex:</td>
&LT;TD bgcolor= "#EBEBEB" ><input type= "Radio" name= "Sex" checked= "checked" value= "Male"/>
Male
<input type= "Radio" name= "Sex" value= "Female"/>
Female</td>
</tr>
<tr>
&LT;TD bgcolor= "#EBEBEB" >Address:</td>
&LT;TD bgcolor= "#EBEBEB" ><input type= "text" name= "Address"/></td>
</tr>
<tr>
&LT;TD colspan= "2" bgcolor= "#EBEBEB" ><div align= "right" >
<input type= "button" Name= "Btnaddprofile" value= "AddNew" onclick= "Mysubmitprofile ()"/>
</div></td>
</tr>
</table></td>
</tr>
</table>
<table width= "100%" border= "0" cellspacing= "0" cellpadding= "0" >
<tr>
&LT;TD height= ><font color= "#FF0000" ><div id= "Stateflag" >state</div></font></td >
</tr>
</table>
</td>
</tr>
<tr>
&LT;TD valign= "Top" >
<table width= "100%" border= "0" cellspacing= "0" cellpadding= "3" >
<tr>
<td><table width= "80%" border= "1" align= "center" cellpadding= "1" cellspacing= "1" >
<tbody id= "Tbcountry" >
<tr>
<td>Company</td>
<td>Country</td>
<td>WebSite</td>
</tr>
</tbody>
</table></td>
</tr>
<tr>
<td><table width= "50%" border= "0" align= "center" cellpadding= "2" cellspacing= "1" bgcolor= "#CCCCCC" >
<tr>
&LT;TD width= "29%" bgcolor= "#EBEBEB" >Company:</td>
&LT;TD width= "71%" bgcolor= "#EBEBEB" ><input type= "text" Name= "Company"/></td>
</tr>
<tr>
&LT;TD bgcolor= "#EBEBEB" >Country:</td>
&LT;TD bgcolor= "#EBEBEB" ><input type= "text" name= "Country"/></td>
</tr>
<tr>
&LT;TD bgcolor= "#EBEBEB" >WebSite:</td>
&LT;TD bgcolor= "#EBEBEB" ><input type= "text" name= "website"/></td>
</tr>
<tr>
&LT;TD colspan= "2" bgcolor= "#EBEBEB" ><div align= "right" >
<input type= "button" Name= "Btnaddcountry" value= "AddNew" onclick= "mysubmitcountry ()"/>
</div></td>
</tr>
</table></td>
<tr>
&LT;TD align= "Right" >
<input type= "button" value= "NEXT" onclick= "Javascript:window.open (' dojobind.htm ', ' _self ')"/>
</td>
</tr>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.