Вы находитесь на странице: 1из 40

Create a home Page about you with a appropriate image and 15 lines introducing you with hyperlinks to About

t your + people who have made difference to your life About your friends Your dreams and aspirations 10 things you wish in life 10 things you dont wish to do but you have to do! Unforgettable moments in your life! Your skills or services
Aboutme.html
<html> <head><title>--- About Me---</title></head> <body background="bbg.jpg"> <fonr face="impact">About Me</font>&nbsp; <hr> <font face="Dungeon" color="Brown"><center><b>Hello i am<u> Anshul Mishra</u>..I am what i am.Thats true...i dont want to be like some one else .. <br>I am just trying to be a good Human Being ..not more than that.</br>I am 20 year old.I live in vashi navi mumbai<br>One Day i will be what i wanted to BE*** </center></b></font> <hr> <table cellpadding="15"> <tr> <td> <img src="b3.jpg" width="500px"/> </td> <td> <ul type="square"> <font face="harlow solid italic"> <h2><li><a href="greatppl.html">Great people in life!</a><br> <li><a href="friends.html">My Friends</a><br> <li><a href="dreams.html">Dreams And Aspirations</a><br> <li><a href="wish.html">My Wishes</a><br> <li><a href="dislikes.html">I dont like!</a><br> <li><a href="memories.html">Unforgettable memories</a> <li><a href="skills.html">Skills</a></2></font></ul></td> </table> Click On above inks to get more details about me! </body> </html> Greatppl.html <html> <body> <a href="aboutme.html">Home</a><br><br> <p>I have many friends and people in my life who has helped me to change my life in a positive attitude.</p> </body> </html> Friends.html <html> <a href="aboutme.html">Home</a><br><br> <body>

friends... I dont have lots of friend .. Only having few frnds but all are special for me..<br> Including me. </body> </html> Dreams.html <html> <body> <a href="aboutme.html">Home</a><br><br> <p>I want to live every moment of my life...."LIve life Long"</p> <p>And I aspire to keep my parents happy throughout my life as long as I live.</p> </body> </html> Wish.html <html> <body> <a href="aboutme.html">Home</a><br> <ol type="1"> <li>To pass T.Y</li> <li>Learn all possible things.</li> <li>visit every place which is possible for me.</li> <li>Live my own life....</li> <li>To keep my parents happy.</li> </ol> </body> </html> Dislikes.html <html> <body> <a href="aboutme.html">Home</a><br><br> <ul type="square"> <li>I hate standing in long queues at college campus.</li> <li>I hate some people from the bottom of my heart but still have to bear with them.</li> <li>I hate the people who under estimate me and are still a part of my life.</li> <li>I hate driving in traffic.</li> <li>I hate long jouneys by roadways.</li> <li>I hate giving fake smiles to people but have to do just because being rude is not done generally.</li><ul> </body> </html> Memories.html <html> <body> <a href="aboutme.html">Home</a><br><br> <p>End of 2011 was most memeorable time for me ...this particular period teaches me lots of lesson about this real world</p> </body> </html> Skills.html <html> <body> <a href="aboutme.html">Home</a><br><br>

<h3>Skills</h3> Skills....still i m working on my skill..<br> so i have nothing to write in this particular page </body> </html>

Output:

Create a registration form inside a table with no borders where people can register with you asking for your services.Registration form should have following information about person name, age and email ,date of birth, sexcode(radio buttons), hobbies(checkboxes), address(textarea), country(listbox) required service(textarea).When clicked on submit button, all the information entered should be entered in a alert dialog box.Use appropriate images , phrases ,imagemaps, table format. Do appropriate formatting on everyPage.
<html> <head><script type="text/javascript"> /////////////////---------->display data in alert function show() { var name=document.getElementById('id_name').value; var age=document.getElementById('id_age').value; var emailid=document.getElementById('id_email').value; var day1=document.getElementById('id_day').value; var month1=document.getElementById('id_month').value; var year1=document.getElementById('id_year').value; var address1=document.getElementById("addr").value; var services1=document.getElementById("service").value; var country=document.forms.country.value; //radio button var selection=document.forms.gender; for(i=0;i<selection.length; i++) if(selection[i].checked ==true) //alert(selection[i].value); var gen=selection[i].value; ////chekbox(hobbies) if(document.forms.h1.checked==true) hobby1=document.forms.h1.value; else hobby1=""; if(document.forms.h2.checked==true) hobby2=document.forms.h2.value; else hobby2=""; if(document.forms.h3.checked==true) hobby3=document.forms.h3.value; else hobby3=""; if(document.forms.h4.checked==true) hobby4=document.forms.h4.value; else hobby4=""; if(name !="" && age !="" && day1 !="" && address1 !="" && month1 !="" && year1 !="" && services1 !="" && country !="" && emailid !="") { alert("Name :"+name+"\n"+"Age : "+age+"\n Email-id : "+emailid+"\n"+"Gender :"+gen+"\n Date of birth :"+day1+"/"+month1+"/"+year1+"\n Address : "+address1+"\n Service : "+services1+"\n Country : "+country

+"\n Hobbies : "+hobby1+"."+hobby2+hobby3+hobby4); } else alert("enter Balnk Spaces!"); } /////////////////////////////////////////////////------> /////////////------->isalpha function isalpa(valpa,msg) { var alpa=/^[a-zA-Z \s]+$/; if(valpa.value.match(alpa)) {return true;} else { alert(msg); valpa.focus(); return false; } } ////////////////////////////////////---------> ///////////////////////////---------->isnum function isnum(vnum, msg) { var num=/^[0-9]+$/; if(vnum.value.match(num)) { return true; } else { alert(msg); vnum.focus(); return false; } } //////////////////////////////////--------------> /////////////////////////////////------------->date of birth function isday(vday,msg) { var day=/([0-9]{1,2})/; if(vday.value.match(day) && vday.value >=1 && vday.value <=31){return true;} else { alert(msg); vday.focus(); return false; } } //check month function ismonth(vmonth,msg) { var month=/([0-9]{1,2})/;

if(vmonth.value.match(month) && vmonth.value >=1 && vmonth.value <=12) { return true; } else { alert(msg); vmonth.focus(); return false; } } //check year function isyear(vyear,msg) { var year=/([0-9]{4})/; if(vear.value.match(year) && vyear.value >=1970 && vyear.value <=2011) { return true; } else { alert(msg); vmonth.focus(); return false; } } //////////////////////////////////-----------------> ///////////////////////////////----------------->ismail function ismail(vmail,msg) { len=vmail.length; if((vmail.charAt(1) =='@')||(vmail.charAt(1)=='.')) { alert(msg); return false; } if((vmail.charAt(len-2)=='@')||(vmail.charAt(len-2)=='.')) { alert(msg); return false; } count=0; dotcount=0; for(var i=0;i<len;I++) { if(vmail.charAt(i)=='@') count++; if(vmail.charAt(i)=='.') dotcount++; } if((count !=1)||(dotcount !=1)) { alert(msg); return fasle; }

return true; } ///////////////////////////////--------------> </script></head> <body> <form name="forms"> <table width="500" align="center"> <hr> <p align=center><h2>Student Registration System</h2></p> <hr> <br> <tr> <td>Name</td> <td> <input type="text" id="id_name" onblur="isalpa(document.getElementById('id_name'),'Re-enter name please')"> </td> </tr> <tr> <td>Age</td> <td><input type="text" id="id_age" onblur="isnum(document.getElementById('id_age'),'Enter correct age please!')"></td> </tr> <tr> <td>Email-id</td> <td><input type="text" id="id_email" email-id')"></td> </tr> <tr> <td>Date of birth (dd-mm-yyyy):</td> <td>Day<input type="text" id="id_day" size="2" onblur="isday(document.getElementById('id_day'),'Re-enter day please!')"> month<input type="text" onblur="ismonth(document.getElementById('id_month'),'Re-enter maxlength="2"> maxlength="2" onblur="ismail(document.getElementById('id_email'),'incorrect

month

id="id_month"size="2" please!')"

year<input type="text" id="id_year" size="4" onblur="isyear(document.getElementById('id_year'),'Reenter year please!')" maxlength="4"> </td> </tr> <tr> <td>Gender</td> <td><input type="radio" name="gender" value="male" checked> male <input type="radio" name="gender" value="female">female </td> </tr> <tr> <td>hobbies:</td> <td>

<input type="checkbox" name="h1" value="Reading">Reading <input type="checkbox" name="h2" value="Sports">Sports <input type="checkbox" name="h3" value="Singing">Singing <input type="checkbox" name="h4" value="Dancing">Dancing </td> </tr><tr> <td>Address:</td> <td><textarea name="addr" col="25" row="3"></textarea> </td></tr> <tr> <td>Country:</td> <td><select name="country"> <option value="india">INDIA</option> <option value="bangladesh">BANGLADESH</option> <option value="china">CHINA</option> <option value="nepal">NEPAL</option> </select> </td></tr> <tr> <td>Services:</td> <td><textarea name="service" col="25" row="3"></textarea></td></tr> <tr> <td><input type="button" value="submit" onclick="show()"></td> <td><input type="reset" value="reset" ></td></tr> </table> </form> </body> </html>

Output:

Design a Login Form containing User Name and password. The password should contain max 8characters.When user name and password matches with predefined values, a welcome message should be displayed otherwise error message should be displayed. Maximum 3 attempts should be allowed for wrong passwords otherwise the application should end[Use If]
<html> <head> <script type="text/javascript"> var count=0; function disp() { var name=document.getElementById('i_name').value; var paswd=document.getElementById('i_pass').value; if(name=="ansh" && paswd=="anshul") { alert("welcome -"+name); } else { if(count==0) { alert("invalid username 3 tries left!!"); count++; } else if(count>=1) { if(count==1) { alert("two tries left"); count=2; } else if(count==2) { alert("one try left!"); count=3; } else if(count==3) { alert("sorry !You have zero attempt left.") window.close(); } } }} </script> </head> <form name="f1"> username<input type="text" id="i_name"><br> password<input type="password" id="i_pass"><br> <input type="button" value="submit" onclick="disp()" > </form> </html>

Output:

Create a html page that accepts Principle Amount, No. of Years & Rate of Interest from 3 text fields, when you click Calculate Interest button, the data is sent to a function that returns the simple interest. When you click on Final Amount button, the final amount by adding principle amount and interest should be displayed. [ Use Functions] .
<html> <head> <script type="text/javascript"> var i,j,k,m,n,l,t,f,fa; function interest() { i=document.form1.txtprincipal.value; j=document.form1.txtyear.value; k=document.form1.txtroi.value; m=i*j*k; n=window.eval(m); alert("simple interest is :"+n); return; } function final() { i=document.form1.txtprincipal.value; j=document.form1.txtyear.value; k=document.form1.txtroi.value; m=i*j*k; n=window.eval(m); f=(parseInt(i)+n); fa=window.eval(f); alert("final amount is:"+fa); return; } </script> </head> <body> <form name="form1"> <table> <tr> <td>Principal Amount:</td> <td><input type="text" name="txtprincipal"></td> </tr> <tr> <td>No of Years:</td> <td><input type="text" name="txtyear"></td> </tr> <tr> <td>Rate of Interest:</td> <td><input type="text" name="txtroi"></td> </tr> <tr>

<td><input type="button" value="Calculate Interest" onclick="interest()"></td> <td><input type="button" value="Final amount" onclick="final()"></td> </tr> </table> </form> </body> </html>

Output:

Design a web page to change the background color on mouseover.


<html> <head> <script type="text/javascript"> function change1(color) { document.getElementById("b").bgColor=color; } </script> </head> <body id="b"> <table> <tr>

<td bgcolor="red" onMouseOver="change1('red')">Red</td> <td bgcolor="orange" onMouseOver="change1('orange')">Orange</td> <td bgcolor="silver" onMouseOver="change1('silver')">silver</td> <td bgcolor="green" onMouseOver="change1('green')">Green</td> </tr> </table> </body> </html>

Output:

Create an XML document with XSL and DTD listing your favorite books . Bookstyle.xml
<?xml version="1.0"?> <?xml-stylesheet href="Bookstyle.xsl" type="text/xsl"?> <Bookstore> <Books> <author>anshul</author> <publisher>joycease</publisher> <price>400</price> </Books> <Books> <author>joycease</author> <publisher>Bomin</publisher> <price>300</price> </Books> <Books> <author>Brave way</author> <publisher>BR</publisher> <price>200</price> </Books> <Books> <author>R -Robin</author> <publisher>Rz</publisher> <price>700</price> </Books> </Bookstore>

Bookstyle.xsl
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h3>Book detail</h3> <table border="2"> <tr bgcolor="yellow"> <td>author</td> <td>publisher</td> <td>price</td> </tr> <xsl:for-each select="Bookstore/Books"> <tr> <td><xsl:value-of select="author"/></td> <td><xsl:value-of select="publisher"/></td> <td><xsl:value-of select="price"/></td> </tr> </xsl:for-each> </table> </body>

</html> </xsl:template> </xsl:stylesheet>

Dtd1.xml
<?xml version="1.0"?> <!DOCTYPE Bookstore [ <!ELEMENT Bookstore (book)+> <!ELEMENT Books (author,publisher,price)> <!ELEMENT author (#PCDATA)> <!ELEMENT publisher (#PCDATA)> <!ELEMENT price (#PCDATA)> ]> <Bookstore> <Books> <author>anshul</author> <publisher>joycease</publisher> <price>400</price> </Books> <Books> <author>joycease</author> <publisher>Bomin</publisher> <price>300</price> </Books> <Books> <author>Brave way</author> <publisher>BR</publisher> <price>200</price> </Books> <Books> <author>R -Robin</author> <publisher>Rz</publisher> <price>700</price> </Books> </Bookstore>

Output:

Create an XML document describing your hobbies and interest and relevant activities. Link it to above web page.

Hobby.xml
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="xml2.xsl"?> <Myself> <Hobbies>Playing Cricket, Reading Books</Hobbies> <Interest>Teaching, Games</Interest> <Activities>Sports, Music</Activities> </Myself>

Xml2.xsl
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h3>Create an XML document describing your hobbies and interest and relevant activities. Link it to above web page </h3> <xsl:for-each select="Myself"> <xsl:value-of select="Hobbies"/> <xsl:value-of select="Interest"/> <xsl:value-of select="Activities"/> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>

Output:

Create a html file to fetch the contents of cataglog.xml (CD details) using ajax and display them in a table
Newx.html <html> <head> <script type="text/javascript"> function loadXMLDoc() { var xmlhttp; var txt,x,i; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { xmlDoc=xmlhttp.responseXML; txt=""; x=xmlDoc.getElementsByTagName("ARTIST"); for (i=0;i<x.length;i++) { txt=txt + x[i].childNodes[0].nodeValue + "<br />"; } document.getElementById("myDiv").innerHTML=txt; } } xmlhttp.open("GET","cd_catalog.xml",true); xmlhttp.send(); } </script> </head> <body> <h2>My CD Collection:</h2> <div id="myDiv"> <button type="button" onclick="loadXMLDoc()">Get my CD collection</button> </div> </body> </html>

Cd_catalog.xml
<?xml version="1.0" encoding="utf-8"?> <CATALOG> <CD> <TITLE>BlackDawn</TITLE> <ARTIST>Rounm rOBin</ARTIST> <COUNTRY>INDIA</COUNTRY> <COMPANY>BusyBrains</COMPANY> <PRICE>43.0</PRICE> <YEAR>2022</YEAR> </CD> <CD> <TITLE>Hide your heart</TITLE> <ARTIST>Bonnie Tyler</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>CBS Records</COMPANY> <PRICE>9.90</PRICE> <YEAR>1988</YEAR> </CD> <CD> <TITLE>Greatest Hits</TITLE> <ARTIST>Dolly Parton</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>RCA</COMPANY> <PRICE>9.90</PRICE> <YEAR>1982</YEAR> </CD> <CD> <TITLE>Still got the blues</TITLE> <ARTIST>Gary Moore</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>Virgin records</COMPANY> <PRICE>10.20</PRICE> <YEAR>1990</YEAR> </CD> <CD> <TITLE>Eros</TITLE> <ARTIST>Eros Ramazzotti</ARTIST> <COUNTRY>EU</COUNTRY> <COMPANY>BMG</COMPANY> <PRICE>9.90</PRICE> <YEAR>1997</YEAR> </CD> <CD> <TITLE>One night only</TITLE> <ARTIST>Bee Gees</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>Polydor</COMPANY> <PRICE>10.90</PRICE> <YEAR>1998</YEAR>

</CD> <CD> <TITLE>Romanza</TITLE> <ARTIST>Andrea Bocelli</ARTIST> <COUNTRY>EU</COUNTRY> <COMPANY>Polydor</COMPANY> <PRICE>10.80</PRICE> <YEAR>1996</YEAR> </CD> <CD> <TITLE>When a man loves a woman</TITLE> <ARTIST>Percy Sledge</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Atlantic</COMPANY> <PRICE>8.70</PRICE> <YEAR>1987</YEAR> </CD> <CD> <TITLE>Black angel</TITLE> <ARTIST>Savage Rose</ARTIST> <COUNTRY>EU</COUNTRY> <COMPANY>Mega</COMPANY> <PRICE>10.90</PRICE> <YEAR>1995</YEAR> </CD> <CD> <TITLE>1999 Grammy Nominees</TITLE> <ARTIST>Many</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Grammy</COMPANY> <PRICE>10.20</PRICE> <YEAR>1999</YEAR> </CD> <CD> <TITLE>For the good times</TITLE> <ARTIST>Kenny Rogers</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>Mucik Master</COMPANY> <PRICE>8.70</PRICE> <YEAR>1995</YEAR> </CD> <CD> <TITLE>Big Willie style</TITLE> <ARTIST>Will Smith</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Columbia</COMPANY> <PRICE>9.90</PRICE> <YEAR>1997</YEAR> </CD> <CD> <TITLE>Tupelo Honey</TITLE> <ARTIST>Van Morrison</ARTIST> <COUNTRY>UK</COUNTRY>

<COMPANY>Polydor</COMPANY> <PRICE>8.20</PRICE> <YEAR>1971</YEAR> </CD> <CD> <TITLE>Soulsville</TITLE> <ARTIST>Jorn Hoel</ARTIST> <COUNTRY>Norway</COUNTRY> <COMPANY>WEA</COMPANY> <PRICE>7.90</PRICE> <YEAR>1996</YEAR> </CD> <CD> <TITLE>The very best of</TITLE> <ARTIST>Cat Stevens</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>Island</COMPANY> <PRICE>8.90</PRICE> <YEAR>1990</YEAR> </CD> <CD> <TITLE>Stop</TITLE> <ARTIST>Sam Brown</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>A and M</COMPANY> <PRICE>8.90</PRICE> <YEAR>1988</YEAR> </CD> <CD> <TITLE>Bridge of Spies</TITLE> <ARTIST>T'Pau</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>Siren</COMPANY> <PRICE>7.90</PRICE> <YEAR>1987</YEAR> </CD> <CD> <TITLE>Private Dancer</TITLE> <ARTIST>Tina Turner</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>Capitol</COMPANY> <PRICE>8.90</PRICE> <YEAR>1983</YEAR> </CD> <CD> <TITLE>Midt om natten</TITLE> <ARTIST>Kim Larsen</ARTIST> <COUNTRY>EU</COUNTRY> <COMPANY>Medley</COMPANY> <PRICE>7.80</PRICE> <YEAR>1983</YEAR> </CD> <CD>

<TITLE>Picture book</TITLE> <ARTIST>Simply Red</ARTIST> <COUNTRY>EU</COUNTRY> <COMPANY>Elektra</COMPANY> <PRICE>7.20</PRICE> <YEAR>1985</YEAR> </CD> <CD> <TITLE>Red</TITLE> <ARTIST>The Communards</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>London</COMPANY> <PRICE>7.80</PRICE> <YEAR>1987</YEAR> </CD> <CD> <TITLE>Unchain my heart</TITLE> <ARTIST>Joe Cocker</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>EMI</COMPANY> <PRICE>8.20</PRICE> <YEAR>1987</YEAR> </CD> </CATALOG>

output:

Create a web page to fetch the matching name from the namearray stored in a php file using ajax when you enter the starting alphabet in a textfield.
Fetchdata.html
<html> <head> <script type="text/javascript"> function showHint(str) { if (str.length==0) { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","gethint.php?q="+str,true); xmlhttp.send(); } </script> </head <body> <p><b>Start typing a name in the input field below:</b></p> <form> First name: <input type="text" onkeyup="showHint(this.value)" size="20" /> </form> <p>Suggestions: <span id="txtHint"></span></p> </body> </html>

Gethint.php
<?php // Fill up array with names $a[]="Anshul Mishra"; $a[]="Anita"; $a[]="Brinda"; $a[]="Cinderella"; $a[]="Diana";

$a[]="Eva"; $a[]="Fiona"; $a[]="Gayatri"; $a[]="Heena"; $a[]="Isha"; $a[]="Jigna"; $a[]="Kamla"; $a[]="Leena"; $a[]="Nina"; $a[]="Ophelia"; $a[]="Padmini"; $a[]="Akansha"; $a[]="Rina"; $a[]="Cindy"; $a[]="Diksha"; $a[]="Esha"; $a[]="Evita"; $a[]="Sunita"; $a[]="Trupti"; $a[]="Usha"; $a[]="Samaira"; $a[]="Leena"; $a[]="Edith"; $a[]="Sia"; $a[]="Wiha"; $a[]="Vicky"; //get the q parameter from URL $q=$_GET["q"]; //lookup all hints from array if length of q>0 if (strlen($q) > 0) { $hint=""; for($i=0; $i<count($a); $i++) { if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q)))) { if ($hint=="") { $hint=$a[$i]; } else { $hint=$hint." , ".$a[$i]; } } } } // Set output to "no suggestion" if no hint were found // or to the correct values if ($hint == "") { $response="no suggestion"; }

else { $response=$hint; } //output the response echo $response; ?>

Output:

Create a php file to display welcome message


Wlcm.php
<html> <head> <title>PHP Test</title> </head> <body> <?php echo '<h3><p>Welcome to the World of php-Anshul Mishra</p></h3>'; ?> </body> </html>

Output:

Create a web page to fetch and display the content of a text file on button click using XMLHttpRequest object
Ajaxdemo.html <html> <head> <title>Ajax at work</title> <script language = "javascript"> var XMLHttpRequestObject = false; if (window.XMLHttpRequest) { XMLHttpRequestObject = new XMLHttpRequest(); } else if (window.ActiveXObject) { XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP"); } function getData(dataSource, divID) { if(XMLHttpRequestObject) { var obj = document.getElementById(divID); XMLHttpRequestObject.open("GET", dataSource); XMLHttpRequestObject.onreadystatechange = function() { if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) { obj.innerHTML = XMLHttpRequestObject.responseText; } } XMLHttpRequestObject.send(null); } } </script> </head> <body> <H1>Fetching data with Ajax</H1> <form> <input type = "button" value = "Display Message" onclick = "getData('data.txt', 'targetDiv')"> </form> <div id="targetDiv"> <p>The fetched data will go here.</p> </div> </body> </html>

Data.txt
This is ajax example -by anshul mishra

Output:

Вам также может понравиться