Advertisement
sgbtechsoluation

WT ASS5

Jan 11th, 2022
860
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 11.56 KB | None | 0 0
  1. ASSIGNMENT 5
  2.  
  3. 5.  Develop dynamic web page to demonstrate Positioning Elements, Moving Elements, Element Visibility, changing colours and Fonts, Dynamic Content, Stacking Elements, Locating the Mouse Cursor, reacting to a Mouse Click.
  4.  
  5.  
  6. A.  Design a dynamic web page that contains two radio button labelled foreground colour and background colour and a heading change colour. Place menu which contains minimum ten colours. Menu must be labelled with choose colour. Radiobottons onclick event must trigger the event handler which must apply the chosen colour to option chosen through the radio button. Default foreground colour of heading is green and background is white. While applying the background color radio button visibility must be hidden and at the time of applying foreground color radio button must be visible.
  7.  
  8. Index.html
  9. <!DOCTYPE html>
  10. <html>
  11. <head>
  12. <title> ASSIGNMENT 5 A </title>
  13. <script type="text/javascript" src="a.js"></script>
  14. </head>
  15. <body id="bd" style="background-color: white;"> <!-- To set default Background color as white-->
  16. <h2 id="h" style="color: green;">CHANGE COLOR</h2>  <!-- To set default Foreground color as Green-->
  17. <form id="fr">
  18. <input type="radio" id="b" name="r1" value="back" style="visibility: visible;"/>
  19. <!-- To set Visibility property-->
  20. <label id="l1" style="visibility: visible;">Background Color</label><br/>
  21. <input type="radio" id="f" name="r1" value="fore" style="visibility: visible;"/>
  22. <label id="l2" style="visibility: visible">Foreground Color</label><br/>
  23. <h4> Choose Color</h4><br/><br/>
  24. <select id="s" onchange="change();">    <!-- To create Menu-->
  25. <option>--choose color--</option>
  26. <option value="purple">Purple</option>
  27. <option value="green">Green</option>
  28. <option value="blue">Blue</option>
  29. <option value="violet">Violet</option>
  30. <option value="yellow">yellow</option>
  31. <option value="orange">Orange</option>
  32. <option value="indigo">Indigo</option> </select><br/><br/>
  33. <input type="button" id="r" value="REPEAT" onclick="reappear();"/><br/>
  34.  
  35. </form>
  36. </body>
  37. </html>
  38.  
  39. function change()
  40. {
  41.  
  42.  
  43.  
  44.  
  45. a.js
  46.  
  47. s=document.getElementById("s"); // To fetch value clicked at menu v=s.value;
  48. f=document.getElementById("fr"); h=document.getElementById("h").style; if(f.r1[0].checked)
  49. {
  50. document.getElementById("bd").style.backgroundColor=v; document.getElementById("b").style.visibility="hidden";  // To hide Element document.getElementById("f").style.visibility="hidden"; document.getElementById("l1").style.visibility="hidden"; document.getElementById("l2").style.visibility="hidden";
  51. }
  52. else if(f.r1[1].checked)
  53. {
  54. h.color=v;
  55. }
  56. }
  57. function reappear() // To again set initial initial value
  58. {
  59. document.getElementById("b").style.visibility="visible"; document.getElementById("f").style.visibility="visible"; document.getElementById("l1").style.visibility="visible"; document.getElementById("l2").style.visibility="visible";
  60. }
  61.  
  62. ………………………………………………..OUTPUT………………………………………………….
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72. B.Design a dynamic web page to fill the customer information Name and Email. Also the user must provide the userid and password details required to create an account. Provide Helpbox to assist the user in filling the form. Onbulr event of textboxes must position helpbox nearer to the textbox and must contain help message related to the information to be filled in the box. Helpbox is represented through the text area and initial content is plz look into this box to fill the form. Web page must contain submit and reset button. Onclick event of submit button trigger the event handler which must validates the entered name, email and password are in required format or not. In case any one is not in given format alert the user with a message your details are not accepted otherwise display the accepted details.
  73. Index.html
  74. <html>
  75.     <head>
  76.         <script type="text/javascript" src="5b.js"></script>
  77.     </head>
  78.     <body>
  79.      <form align="center" style="font-family: Arial; padding: 30px;font-size:1.8em;background-color:blue;
  80.           margin: 30px">
  81.             <pre>Name       :<input type="text" id="name" onfocus="help_box(1);"
  82. onblur="help_box(0);"></pre>
  83.             <pre>E-mail     :<input type="text" id="mail" onfocus="help_box(2);"
  84. onblur="help_box(0);"></pre>
  85.             <pre>User-id    :<input type="text" id="uid" onfocus="help_box(3);"
  86.             onblur="help_box(0);"></pre>
  87.             <pre>Password   :<input type="text" id="pass" onfocus="help_box(4);"
  88.             onblur="help_box(0);"></pre>
  89.         <textarea rows="1" cols="60" id="box" style="position:absolute; top:90px;left:1165px;">
  90.           Please look into this box to fill the form</textarea>
  91.         <input type="submit" value="SUBMIT" onclick="validate();"/>  
  92.         <input type="reset" value="RESET" onclick="del();"/>
  93.         </form>
  94.    </body>
  95. </html>
  96. b.js
  97. var a=["Please refer this box to fill the form","Firstname,lastname,Middle-initial.", "username(digit,lowercase)@com","User@(3digit)","length-
  98. 6,lowercase,Uppercase,special char[@$!_],digit"]; function help(k)
  99. {
  100. p=document.getElementById("ta").style; document.getElementById("ta").value=a[k]; if(k===0)
  101. {
  102. p.top="10px"; p.left="450px";
  103. }
  104. else
  105. {
  106. p.top="30px"; p.left="300px";
  107. }
  108. }
  109. // [A-Z][a-z]+[,][A-Z][a-z]+[,][A-Z]
  110. function validate()
  111. {
  112. nv=document.getElementById("n").value.search(/[A-Z][a-z]+[,][A-Z][a-z]+[,][A- Z]$/);
  113. console.log(nv);
  114. ev=document.getElementById("e").value.search(/^[a-z][0-9a-z]*@gmail\.com/); uv=document.getElementById("u").value.search(/User@\d{3}/);
  115. if(nv!==-1&&ev!==-1&&uv!==-1)
  116. {
  117. alert("Valid data");
  118. }
  119. else
  120. {
  121. alert("Invalid data and cannot be uploaded");
  122. }
  123. }
  124.  
  125. var a=["Please refer this box to fill the form","Firstname,lastname,Middle-initial", "username(digit,lowercase)@(domain)com","Name(3digit)","length-
  126. 6,uppercase,lowercase,special character like[@$!_],digit"]; function help_box(k)
  127. {
  128. new_style=document.getElementById("box").style; document.getElementById("box").value=a[k]; if(k===0)
  129. {
  130. new_style.top="80px";
  131.  
  132. new_style.left="500px";
  133. }
  134. if(k==1)
  135. {
  136. new_style.top="80px"; new_style.left="400px";
  137. }
  138. if(k==2)
  139. {
  140. new_style.top="110px"; new_style.left="400px";
  141. }
  142. if(k==3)
  143. {
  144. new_style.top="140px"; new_style.left="400px";
  145. }
  146. if(k==4)
  147. {
  148. new_style.top="170px"; new_style.left="400px";
  149. }
  150.  
  151.  
  152. }
  153.  
  154. function validate()
  155. {
  156. nv=document.getElementById("name").value.search(/[A-Z][a-z]+[,][A-Z][a- z]+[,][A-Z]$/);
  157. ev=document.getElementById("mail").value.search(/^[a-z0-9]*@[a- z]{4,6}\.com/);
  158. uv=document.getElementById("uid").value.search(/[A-Z][a-z]+\d{3}/); if(nv!==-1&&ev!==-1&&uv!==-1)
  159. {
  160. if(document.getElementById("pass").value.search(/[A-Za-z0-9@$!_]{6}/)!==-1) alert("Valid data");
  161. }
  162. else
  163. {
  164. alert("Invalid data and cannot be uploaded");
  165. }
  166. }
  167.  
  168. function del()
  169. {
  170. w1= document.getElementById("name").value=" ";
  171.  
  172. w2=document.getElementById("mail").value=" "; w3= document.getElementById("uid").value=" "; w4= document.getElementById("pass").value=" ";
  173. }
  174. ………………………………………………..OUTPUT………………………………………………….
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185. C.Design dynamic web page which must contain four short paragraphs of text about your four favourite places. Each paragraph initially must have different font and border properties. These four paragraphs must be stacked on top of each other, with only enough of each showing so that mouse cursor can always be placed over some part of them. Onmouseover event for these paragraphs must trigger the event handler to bring the triggered paragraph on top and its font and border properties must be changed to the old top paragraph properties and old top paragraph properties must be changed to the current top one.
  186.  
  187. Index.html
  188. <html>
  189.     <head>
  190.         <script>
  191.  var ot="p3";
  192.                 function change(nt)
  193.                 {
  194.                     dot=document.getElementById(ot).style;
  195.                     dnt=document.getElementById(nt).style;
  196.                     dot.zIndex="0";
  197.                     dnt.zIndex="10";
  198.                     otcolor=dot.backgroundColor;
  199.                     ntcolor=dnt.backgroundColor;
  200.                     dnt.backgroundColor=otcolor;
  201.                     dot.backgroundColor=ntcolor;
  202.                     ot=nt;
  203.  
  204.                 }
  205.         </script>
  206.     </head>
  207.     <body>
  208.         <p id="p1" style="position: absolute; top: 20px; left: 0px; font-style: italic;background-color:
  209.           lightsteelblue; color:violate; z-index: 0px; border-style: dashed;border-color: greenyellow;
  210.           border-width: thick;" onclick="change('p1');">Try, try, try and try again. Feed your mind ideas of success, not failure.Remember, the only way you can fail is if you give up. Every time you fail, you come one step closer to success.You are not scared; you are courageous. You are not weak; you are powerful. You are not ordinary, you are remarkable.Do not back down, do not give up.</p>
  211.         <p id="p2" style="position: absolute; top: 60px; left: 75px; font-weight:bold; color:indigo;
  212.           background-color: pink; z-index: 0px; border-style: solid;border-color: blue; border-width: thick;
  213.           " onclick="change('p2');">When you look back on your life, don't have regrets. Believe in yourself,believe in your future, you will find your way.There is a fire burning inside you that is very powerful; it is waiting to burn bright. You are meant to do great things.Following your dreams can be both terrifying and exciting. Courage is facing fear. Fear of failure holds most people back. You are not most people. </p>
  214.         <p id="p3" style="position: absolute; top: 100px; left: 150px; font-style: oblique;
  215.           background-color: palevioletred; color:blue; z-index: 0px; border-style: double;
  216.           border-color: orange; border-width: thick;" onclick="change('p3');">Bijapur is a historical city in Karnataka. The city is famous for its ancient monuments, mosques, mausoleums, palaces,fortifications and other structures. Situated at a distance of about 530 km to the northwest of Bangalore, Bijapur attracts scores of tourists who flock to have a glimpse of the historical, cultural and architectural beauty of the city.</p>
  217.         <p id="p4" style="position: absolute; top: 140px; left: 225px; color:green; z-index: 0px;
  218.           background-color: lightsalmon; border-style: dotted;border-color: black; border-width: thick;
  219.           " onclick="change('p4');">Bijapur is an ancient city that was founded in the 10th-11th century by Kalyani Chalukyas, the then rulers of South India. During that period it was known as Vijayapura which means the ‘City of Victory.’ Later it came under the rule of the Yadavas and then the Bahmani Sultanate of Gulbarga. It was the capital of the Adil Shahi kings from 1489 to 1686.</p>
  220.         </body>
  221. </html>
  222.  
  223.  
  224.  
  225.  
  226.  
  227. ………………………………………………..OUTPUT………………………………….
  228.    
  229.  
  230.  
  231.  
  232. D.Design dynamic web page to display your image. Continuously move the image along with mouse cursor position.
  233.  
  234.  
  235. Index.html
  236. <html>
  237. <head>
  238. <title> ASSIGNMENT 5 D </title>
  239. <script type="text/javascript" src="d.js"></script>
  240. </head>
  241. <body onmouseover="move(event);"> <!-- Bringing mouse cursor to link event -->
  242. <img src="becimg.jfif" alt="Hi" id="i" style="position: absolute; top: 10px; left:10px;" width="105" height="100"/>
  243. </body>
  244. </html>
  245.  
  246. d.js
  247. function move(e)
  248. {
  249. document.getElementById("i").style.top=e.clientY+"px"; document.getElementById("i").style.left=e.clientX+"px";
  250. }
  251.  
  252. ………………………………………………..OUTPUT………………………………………………….
  253.  
  254.  
  255.  
  256.  
  257.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement