Slip 19 - B) Write a Ajax program to get book details from XML file when user select book name. Create XML file to store details of book(name, author, year and price).

 Solution:

<html>
<body>
<script type="text/javascript">
function show_confirm()
{
var r=confirm("Press a button !");
if(r==true)
{
ver i;
var mybooks = new Array();
mybooks[0]="Mysql";
mybooks[1]="PHP";
mybooks[2]="Java";
for(i=0;i {
document.write(mybookks[i]+"
");
}
}
else
{

alert("Cancel books cannot br displayed !");
}
}
</script>
</head>
<body>
<input type="button" onclick="show_confirm()" value="List of Books"/>
</body>
</html>

File.xml

<?xml version='1.0' encoding='utf-8'?>
//use to double qoute for display version "1.0" and "utf-8".don't use singlr qoute.
<ABCBOOLK>
<Book>
<Book_Title>Networking</Book_Title>
<Book_Author>400</Book_Author>
<Book_PubYear>2015</Book_PubYear>
<Book_Price>450</Book_Price>
</Book>
<Book>
<Book_Title>php </Book_Title>
<Book_Author>400</Book_Author>
<Book_PubYear>2015</Book_PubYear>
<Book_Price>450</Book_Price>
</Book>
<Book>
<Book_Title>java</Book_Title>
<Book_Author>400</Book_Author>
<Book_PubYear>2015</Book_PubYear>
<Book_Price>450</Book_Price>
</Book>
</ABCBOOLK>


Post a Comment

0 Comments