0% found this document useful (0 votes)
21 views37 pages

DHTML Assignment (3&4)

The document contains a series of jQuery and XML programming exercises, including examples of alert messages, context menu interactions, scrolling to the top of a page, and creating structured XML documents for books, students, and employees. Each section provides input code and expected output, demonstrating various functionalities and structures in jQuery and XML. The exercises aim to enhance understanding of web development and data representation using these technologies.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views37 pages

DHTML Assignment (3&4)

The document contains a series of jQuery and XML programming exercises, including examples of alert messages, context menu interactions, scrolling to the top of a page, and creating structured XML documents for books, students, and employees. Each section provides input code and expected output, demonstrating various functionalities and structures in jQuery and XML. The exercises aim to enhance understanding of web development and data representation using these technologies.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 37

NAME – SHAH KELCY ROLL NO- 20-BCA-141

CH :- 4 [ JQuery ]
22. Write a simple jquery program to print alert message hello world.

Input:-

<html>

<head>

<title>jQuery</title>

<script src="jquery-3.6.0.js"></script>

<script>

$(document).ready(function(){

$("#in").click(function(){

alert("HELLO WORLD!");

});

});

</script>

</head>

<body bgcolor="cyan">

<center>

<h1 style="font-family: cursive;">Click The Button</h1><hr><br>

<input type="button" id="in" value="Click Me">

</center>

</body>

</html>

Output:-
NAME – SHAH KELCY ROLL NO- 20-BCA-141
NAME – SHAH KELCY ROLL NO- 20-BCA-141

23. Test if jQuery is loaded.

Input:-

<html>

<head>

<title>Check jQuery is Loaded</title>

<script src="jquery-3.6.0.js"></script>

<script>

$(document).ready(function() {

$(".in").click(function() {

if (jQuery) {

alert("Yeah!");

} else {

alert("Doesn't Work");

});

});

</script>

</head>

<body bgcolor="cyan">

<center>

<h1 style="font-family: cursive;">Check The jQuery</h1><hr><br>

<input type="button" value="Check" class="in">

</center>

</body>

</html>

Ouptut:-
NAME – SHAH KELCY ROLL NO- 20-BCA-141
NAME – SHAH KELCY ROLL NO- 20-BCA-141

24. Scroll to the top of the page with jQuery

Input:-

<html>

<head>

<title>Scroll Page</title>

<script src="jquery-3.6.0.js"></script>

<script>

$(document).ready(function(){

$(".top").click(function(){

$(window).scrollTop(0)

});

});

</script>

<style>

h1,p{font-family: cursive;}

</style>

</head>

<body bgcolor="cyan">

<h1>jQuery</h1><hr>

<p>jQuery</p>

<p>jQuery</p>

<p>jQuery</p>

<p>jQuery</p>

<p>jQuery</p>
NAME – SHAH KELCY ROLL NO- 20-BCA-141

<p>jQuery</p>

<p>jQuery</p>

<p>jQuery</p>

<p>jQuery</p>

<p>jQuery</p>

<p>jQuery</p>

<p>jQuery</p>

<p>jQuery</p>

<p>jQuery</p>

<input type="button" value="Go Top" class="top">

</body>

</html>

Output :-
NAME – SHAH KELCY ROLL NO- 20-BCA-141

25. Disable right click menu in html page using jquery

Input:-

<html>

<head>

<title>Right Click Disable</title>

<script src="jquery-3.6.0.js"></script>

<script>

$(document).ready(function() {

$("#disable").on("contextmenu",function(){

alert('Right Click Disabled');

return false;

});

});

</script>

</head>

<body>

<center>

<font>Using right click is blocked</font>

<img id="disable" src="Wallpaper.jpg">

</center>
NAME – SHAH KELCY ROLL NO- 20-BCA-141

</body>

</html>

Output:-
NAME – SHAH KELCY ROLL NO- 20-BCA-141

26. Write a jquery for Limit character input in the text area including count

Input:-

<html>

<head>

<title>Limit in textarea</title>

<script src="jquery-3.6.0.js"></script>

<script>

$(document).ready(function(){

var maxlen = 20;

$('#textarea').keyup(function() {

var textlen = maxlen - $(this).val().length;

$('#text').text(textlen);

});

});
NAME – SHAH KELCY ROLL NO- 20-BCA-141

</script>

</head>

<body style="background-color: aqua; font-family: cursive;">

<center>

<form>

<label>Maximum 15 characters</label><hr><br>

<textarea id="textarea" maxlength="15" rows="5" cols="10"></textarea>

<span id="text">15</span><hr>

</form>

</center>

</body>

</html>

Output:-

27. Write a jquery to Display a


message when the context menu event is triggered on the paragraph elements.

Input:-

<html>

<head>

<title>Right Click Alert box</title>

<script src="jquery-3.6.0.js"></script>

<script>

$('document').ready(function(){

$('#click').contextmenu(function(){

alert("Hello Everyone!!");

});
NAME – SHAH KELCY ROLL NO- 20-BCA-141

});

</script>

</head>

<body style="background-color: cyan; font-family: cursive;">

<center>

<h1>Click on Below Text For ALert Msg</h1><hr><br>

<u><p id="click">Right On this Text</p></u>

</center>

</body>

Output:-
NAME – SHAH KELCY ROLL NO- 20-BCA-141

CH :- 4 [ XML ]
28. Create an XML document template to describe the book structure which contains publish year.
According to book publish year it show as book title, author & publication.

Input:-

<?xml version="1.0" encoding="UTF-8"?>

<book_detail>

<book year="1896">

<title>War and Peace</title>

<author>Leo Tolstoy</author>

<publication>Grupo Planeta</publication>

<price>30$/-</price>

</book>

<book year="2012">
NAME – SHAH KELCY ROLL NO- 20-BCA-141

<title>The Fault in Our Stars</title>

<author>John Green</author>

<publication>Wolters Kluwer</publication>

<price>25$/-</price>

</book>

<book year="1974">

<title>The Bermuda Triangle</title>

<author>Charles Berlitz</author>

<publication>Scholastic</publication>

<price>35$/-</price>

</book>

<book year="1975">

<title>Life After Life</title>

<author>Raymond Moody</author>

<publication>Bertelsmann</publication>

<price>45$/-</price>

</book>

<book year="1928">

<title>The Story of My Experiments with Truth</title>

<author>Mohandas Karamchand Gandhi</author>

<publication>Penguin Random House India.</publication>

<price>15$/-</price>

</book>

</book_detail>

Output:-
NAME – SHAH KELCY ROLL NO- 20-BCA-141

29. Create an XML document to demonstrate how to add attribute and sub element in the examination
structure. The description should include the student's roll number, name, three subject names and
their marks, total marks, percentage and result.

Input:-

<?xml version="1.0" encoding="UTF-8"?>

<student_detail>

<student rollno="1">

<name>Priyanshu</name>

<subject>

<sub1>

<Sub>C++</Sub>

<marks>97/100</marks>
NAME – SHAH KELCY ROLL NO- 20-BCA-141

</sub1>

<sub2>

<Sub>HTML</Sub>

<marks>98/100</marks>

</sub2>

<sub3>

<Sub>JAVA</Sub>

<marks>90/100</marks>

</sub3>

</subject>

<total>285/300</total>

<percentage>95%</percentage>

<result>O+(Pass)</result>

</student>

<student rollno="2">

<name>Priya</name>

<subject>

<sub1>

<Sub>C++</Sub>

<marks>97/100</marks>

</sub1>

<sub2>

<Sub>HTML</Sub>

<marks>96/100</marks>

</sub2>

<sub3>

<Sub>JAVA</Sub>

<marks>95/100</marks>
NAME – SHAH KELCY ROLL NO- 20-BCA-141

</sub3>

</subject>

<total>288/300</total>

<percentage>96%</percentage>

<result>O+(Pass)</result>

</student>

<student rollno="3">

<name>Chetna</name>

<subject>

<sub1>

<Sub>C++</Sub>

<marks>92/100</marks>

</sub1>

<sub2>

<Sub>HTML</Sub>

<marks>90/100</marks>

</sub2>

<sub3>

<Sub>JAVA</Sub>

<marks>85/100</marks>

</sub3>

</subject>

<total>267/300</total>

<percentage>89%</percentage>

<result>A+(Pass)</result>

</student>

<student rollno="4">
NAME – SHAH KELCY ROLL NO- 20-BCA-141

<name>Dhvji</name>

<subject>

<sub1>

<Sub>C++</Sub>

<marks>95/100</marks>

</sub1>

<sub2>

<Sub>HTML</Sub>

<marks>90/100</marks>

</sub2>

<sub3>

<Sub>JAVA</Sub>

<marks>92/100</marks>

</sub3>

</subject>

<total>277/300</total>

<percentage>92.33%</percentage>

<result>O+(Pass)</result>

</student>

<student rollno="5">

<name>Aditya</name>

<subject>

<sub1>

<Sub>C++</Sub>

<marks>90/100</marks>

</sub1>

<sub2>

<Sub>HTML</Sub>
NAME – SHAH KELCY ROLL NO- 20-BCA-141

<marks>91/100</marks>

</sub2>

<sub3>

<Sub>JAVA</Sub>

<marks>80/100</marks>

</sub3>

</subject>

<total>261/300</total>

<percentage>87%</percentage>

<result>A+(Pass)</result>

</student>

</student_detail>

Output:-

30. Create an XML document for


employee structure which contains employee no, employee name, department, designation, salary.

Input:-
NAME – SHAH KELCY ROLL NO- 20-BCA-141

<?xml version="1.0" encoding="UTF-8"?>

<employee_detail>

<employee>

<emp_no>5001</emp_no>

<name>Priyanshu</name>

<department>IT Sector</department>

<designation>Senior Manager</designation>

<salary>1,50,000/-Rs.</salary>

</employee>

<employee>

<emp_no>5002</emp_no>

<name>Chetna</name>

<department>IT Sector</department>

<designation>CEO (Chief executive officer)</designation>

<salary>2,00,000/-Rs.</salary>

</employee>

<employee>

<emp_no>5003</emp_no>

<name>Priya</name>

<department>Management</department>

<designation>PA (Personal Assistant)</designation>

<salary>1,00,000/-Rs.</salary>

</employee>

<employee>

<emp_no>5004</emp_no>

<name>Dhvji</name>
NAME – SHAH KELCY ROLL NO- 20-BCA-141

<department>Desginning Sector</department>

<designation>Graphics Desginer</designation>

<salary>1,00,000/-Rs.</salary>

</employee>

<employee>

<emp_no>5005</emp_no>

<name>Aditya</name>

<department>IT Sector</department>

<designation>Account Manager</designation>

<salary>1,00,000/-Rs.</
salary>

</employee>

</employee_detail>

Output:-
NAME – SHAH KELCY ROLL NO- 20-BCA-141

32 & 33. Write program to demonstrate how to add character Entity and text Entity in XML document.

Input:-

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<!DOCTYPE college [

<!ELEMENT college (info+)>

<!ELEMENT info (project,name,rollno,clg)>

<!ELEMENT project (#PCDATA)>

<!ELEMENT name (#PCDATA)>

<!ELEMENT rollno (#PCDATA)>

<!ELEMENT clg (#PCDATA)>

<!ENTITY clg "St.Xaviers College">

<!ENTITY copyright "&#169;">

]>

<college>

<info>

<project>Science &copyright;</project>

<name>Priyanshu</name>

<rollno>105</rollno>

<clg>&clg;</clg>

</info>

<info>

<project>Bussiness &copyright;</project>

<name>Chetna</name>

<rollno>101</rollno>

<clg>&clg;</clg>

</info>

<info>
NAME – SHAH KELCY ROLL NO- 20-BCA-141

<project>Management &copyright;</project>

<name>Priya</name>

<rollno>74</rollno>

<clg>&clg;</clg>

</info>

<info>

<project>Science &copyright;</project>

<name>Aditya</name>

<rollno>16</rollno>

<clg>HL College</clg>

</info>

<info>

<project>Science &copyright;</project>

<name>Dhvji</name>

<rollno>139</rollno>

<clg>&clg;</clg>

</info>

</college>

Output:-
NAME – SHAH KELCY ROLL NO- 20-BCA-141

34. Create internal DTD declaration for BOOKs XML document.

Input:-

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE book_detail[

<!ELEMENT book_detail (book+)>

<!ELEMENT book (title,year,author,publication,price)+>

<!ELEMENT title (#PCDATA)>

<!ELEMENT year (#PCDATA)>

<!ELEMENT author (#PCDATA)>

<!ELEMENT publication (#PCDATA)>

<!ELEMENT price (#PCDATA)>

]>

<book_detail>

<book>

<title>War and Peace</title>

<year>1896</year>

<author>Leo Tolstoy</author>

<publication>Grupo Planeta</publication>

<price>30$/-</price>

</book>

<book>

<title>The Fault in Our Stars</title>

<year>2012</year>

<author>John Green</author>
NAME – SHAH KELCY ROLL NO- 20-BCA-141

<publication>Wolters Kluwer</publication>

<price>25$/-</price>

</book>

<book>

<title>The Bermuda Triangle</title>

<year>1974</year>

<author>Charles Berlitz</author>

<publication>Scholastic</publication>

<price>35$/-</price>

</book>

<book>

<title>Life After Life</title>

<year>1975</year>

<author>Raymond Moody</author>

<publication>Bertelsmann</publication>

<price>45$/-</price>

</book>

<book>

<title>The Story of My Experiments with Truth</title>

<year>1928</year>

<author>Mohandas Karamchand Gandhi</author>

<publication>Penguin Random House India.</publication>

<price>15$/-</price>

</book>

</book_detail>

Output:-
NAME – SHAH KELCY ROLL NO- 20-BCA-141

35. Create External DTD declaration for BOOKs XML document.(Element type declaration)
NAME – SHAH KELCY ROLL NO- 20-BCA-141

Input:-

<!ELEMENT book_detail (book+)>

<!ELEMENT book (title,year,author,publication,price)>

<!ELEMENT title (#PCDATA)>

<!ELEMENT year (#PCDATA)>

<!ELEMENT author (#PCDATA)>

<!ELEMENT publication (#PCDATA)>

<!ELEMENT price (#PCDATA)>

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE book_detail SYSTEM "Que8_DTD.dtd">

<book_detail>

<book>

<title>War and Peace</title>

<year>1896</year>

<author>Leo Tolstoy</author>

<publication>Grupo Planeta</publication>

<price>30$/-</price>

</book>

<book>

<title>The Fault in Our Stars</title>

<year>2012</year>

<author>John Green</author>

<publication>Wolters Kluwer</publication>
NAME – SHAH KELCY ROLL NO- 20-BCA-141

<price>25$/-</price>

</book>

<book>

<title>The Bermuda Triangle</title>

<year>1974</year>

<author>Charles Berlitz</author>

<publication>Scholastic</publication>

<price>35$/-</price>

</book>

<book>

<title>Life After Life</title>

<year>1975</year>

<author>Raymond Moody</author>

<publication>Bertelsmann</publication>

<price>45$/-</price>

</book>

<book>

<title>The Story of My Experiments with Truth</title>

<year>1928</year>

<author>Mohandas Karamchand Gandhi</author>

<publication>Penguin Random House India.</publication>

<price>15$/-</price>

</book>

</book_detail>

Output:-
NAME – SHAH KELCY ROLL NO- 20-BCA-141
NAME – SHAH KELCY ROLL NO- 20-BCA-141

36. Write program to demonstrate the valid DTD & well-formed XML documents.

Input:-

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<!DOCTYPE Detail[

<!ELEMENT Detail (info+)>

<!ELEMENT info (fname,lname,age,college,course)>

<!ELEMENT fname (#PCDATA)>

<!ELEMENT lname (#PCDATA)>

<!ELEMENT age (#PCDATA)>

<!ELEMENT college (#PCDATA)>

<!ELEMENT course (#PCDATA)>

]>

<Detail>

<info>

<fname>Priyanshu</fname>

<lname>Parmar</lname>

<age>19</age>

<college>St.Xavier's</college>

<course>BCA</course>

</info>

<info>

<fname>Chetna</fname>

<lname>Parmar</lname>

<age>19</age>

<college>St.Xavier's</college>

<course>BCA</course>

</info>
NAME – SHAH KELCY ROLL NO- 20-BCA-141

<info>

<fname>Priya</fname>

<lname>Limbani</lname>

<age>19</age>

<college>St.Xavier's</college>

<course>BCA</course>

</info>

<info>

<fname>Dhvji</fname>

<lname>Shah</lname>

<age>19</age>

<college>St.Xavier's</college>

<course>BCA</course>

</info><info>

<fname>Dev</fname>

<lname>Patel</lname>

<age>19</age>

<college>St.Xavier's</college>

<course>BCA</course>

</info>

</Detail>

Output:-
NAME – SHAH KELCY ROLL NO- 20-BCA-141

37. Write program to demonstrate sequence, occurrence & choices in DTD

Input:-

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<!DOCTYPE letter[

<!ELEMENT letter (note+)>

<!ELEMENT note (to,from?,body*,city)>

<!ELEMENT to (#PCDATA)>

<!ELEMENT fname (#PCDATA)>

<!ELEMENT lname (#PCDATA)>

<!ELEMENT from (#PCDATA)>

<!ELEMENT body (#PCDATA)>

<!ELEMENT city (Ahmedabad|Dubai)>

<!ELEMENT Ahmedabad (#PCDATA)>

<!ELEMENT Dubai (#PCDATA)>

]>

<letter>

<note>

<to>Priyanshu</to>

<from>Chetna</from>

<body>

Hello Priyanshu!

</body>

<city>

<Ahmedabad>Sent from Ahmedabad</Ahmedabad>


NAME – SHAH KELCY ROLL NO- 20-BCA-141

</city>

</note>

<note>

<to>Chetna</to>

<from>Priyanshu</from>

<body>

Hi Chetna!

</body>

<city>

<Dubai>Sent from Dubai</Dubai>

</city>

</note>

</letter>

Output:-
NAME – SHAH KELCY ROLL NO- 20-BCA-141

38. Write a program to describe Empty, Any and Mixed content in DTD.

Input:-

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<!DOCTYPE mybook [

<!ELEMENT mybook ANY>

<!ELEMENT book (title,author,price,country)>

<!ELEMENT title (#PCDATA)>

<!ELEMENT author (#PCDATA|name)*>

<!ELEMENT name (#PCDATA)>

<!ELEMENT price (#PCDATA)>

<!ELEMENT country (India|US)>

<!ELEMENT India EMPTY>

<!ELEMENT US EMPTY>

]>

<mybook>

This is a list of books with details.

<book>

<title>Five Point Someone</title>

<author>Chetan Bhagat</author>

<price>$2.99</price>

<country>

<India></India>

</country>

</book>

<book>

<title>I too had a Love Story</title>

<author>
NAME – SHAH KELCY ROLL NO- 20-BCA-141

<name>Ravindra Singh</name>

</author>

<price>$1.99</price>

<country>

<US></US>

</country>

</book>

<book>

<title>Life's Truth</title>

<author>Mohandas Karamchand Gandhi</author>

<price>$2.99</price>

<country>

<India></India>

</country>

</book>

<book>

<title>The Bermuda Triangle</title>

<author>

<name>Charles Berlitz</name>

</author>

<price>$1.99</price>

<country>

<US></US>

</country>

</book>

</mybook>

Output:-
NAME – SHAH KELCY ROLL NO- 20-BCA-141
NAME – SHAH KELCY ROLL NO- 20-BCA-141

39. Write a program to describe string & enumerated Attributes declaration in DTD.

Input:-

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<!DOCTYPE STUDENT_DETAIL

<!ELEMENT STUDENT_DETAIL (student+)>

<!ELEMENT student (name,dob,place,college)>

<!ATTLIST student class CDATA #REQUIRED>

<!ATTLIST student gender (male|female|other) "male">

<!ELEMENT name (#PCDATA)>

<!ELEMENT dob (#PCDATA)>

<!ELEMENT place (#PCDATA)>

<!ELEMENT college (#PCDATA)>

<!ENTITY college "St.Xaviers College">

<!ENTITY copyright "&copyright;">

]>

<STUDENT_DETAIL>

<student class="SY" gender="male">

<name>Priyanshu</name>

<dob>29-11-02</dob>

<place>Ahmedabad</place>

<college>&college;</college>

</student>

<student class="SY" gender="female">

<name>Chetna</name>

<dob>17-11-02</dob>

<place>Ahmedabad</place>
NAME – SHAH KELCY ROLL NO- 20-BCA-141

<college>&college;</college>

</student>

<student class="TY" gender="male">

<name>Aditya</name>

<dob>3-1-99</dob>

<place>Ahmedabad</place>

<college>HL College</college>

</student>

<student class="SY" gender="female">

<name>Priya</name>

<dob>13-5-03</dob>

<place>Ahmedabad</place>

<college>&college;</college>

</student>

</STUDENT_DETAIL>

Output:-

You might also like