Web Technology Slip 18Write a java script program to accept the value of n and display all odd numbers up to n. Answer : <html> <head> <script> function saurabh() { var start = document.getElementById("start").value; var end = document.getElementById("end").value; var oddNums = "<br>Odd Numbers:<br>"; for(i=start; i<=end; i++){ if(i % 2 != 0){ oddNums += i + "<br>"; } } document.getElementById("result").innerHTML = oddNums; } </script> </head> Start: <input id="start" > End: <input id="end" > <button onclick="saurabh()">click</button> <div id="result"></div> </html> CopyWrite the HTML code which generates the following output. (Use external CSS to format the given table) Answer : <!DOCTYPE html> <html> <title>assignment3</title> <body> <table width="50%" align="left" cellpadding="1" cellspacing="1" border="1"> <tr> <td rowspan="2">Book_No</td> <td rowspan="2">Book_Name</td> <td colspan="2" width="50%" align="center"><b>Price</b></td> </tr> <tr align="center"> <td width="25%"><b>RS</b></td> <td><b>Paise</b></td> </tr> <tr> <td>101</td> <td>DBMS</td> <td>200</td> <td>50</td> </tr> <tr> <td>102</td> <td>C-Prog</td> <td>150</td> <td>75</td> </tr> <tr> <td>103</td> <td>JAVA</td> <td>300</td> <td>00</td> </tr> <tr> <td>104</td> <td>PHP</td> <td>250</td> <td>50</td> </tr> <tr> <td>105</td> <td>ASP</td> <td>100</td> <td>00</td> </tr> </table> </body> </html> Copy
No comments:
Post a Comment