Important program for css exam (1)
Important program for css exam (1)
Write a HTML script which displays 2 radio buttons to the users for fruits and
vegetable and 1 option list. When user select fruits radio button option list should
present only fruits names to the user & when user select vegetable radio button
option list should present only vegetable names to the user.
<html>
<head>
<title>D1</title>
<script>
function DisplayList(ElementValue)
with(document.forms.frm1)
if(ElementValue==1)
op1[0].text="mango";
op1[0].value=1
op1[1].text="Banana";
op1[1].value=2
op1[1].text="Banana";
op1[1].value=3
if(ElementValue==2)
op1[0].text="Onion";
op1[0].value=1
op1[1].text="Potato";
op1[1].value=2
op1[1].text="Spinich";
op1[1].value=3
</script>
</head>
<body>
<option value=1>Mango
<option value=2>Banana
<option value=3>Apple
</select>
<br>
</form>
</body>
</html>
Output
Q Describe, how to read cookie value and write a cookie value. Explain with example.-
6 marks
<html>
<head>
<script>
function write()
var cookievalue=username.value;
document.cookie="username="+cookievalue+";expires=T
hu";
alert("cookie is write");
function read()
var cookievalue=username.value;
var a=document.cookie="username="+cookievalue;
</script>
</head>
<body>
</body>
</html>
Q. Write a Java script that displays textboxes for accepting name & email ID & a
submit button. Write Java script code such that when the user clicks on submit
button.- 6marks
1: Name Validation
<html>
<head>
</head>
<title>
form1</title>
<body>
</form>
</body>
</html>
<script type="text/javascript">
function validate()
if(document.myfrom.name.value=="")
document.myfrom.name.focus();
return false;
if(document.myfrom.email.value=="")
return false;
var emailId=document.myfrom.email.value;
atpos=emailId.indexOf("@");
dotpos=emailId.lastIndexOf(".");
if(atpos<1||(dotpos-atpos<2))
document.myfrom.email.focus();
return false;
return(true);
</script>
Output
Q6.2
[9:07 pm, 09/12/2023] Malegaon Gaikwad Sir: Que. IMPLEMENTING BANNER
<html>
<head>
</style>
<script>
mybanners=new Array('santu.jpg','viru.jpg','dinesh.jpg');
banner_count=0;
function Display()
if(document.images)
banner_count++;
if(banner_count==mybanners.length)
banner_count=0;
document.BannerChange.src=mybanners[banner_count];
setTimeout("Display()",3000);
</script>
</head>
<body onload="Display()">
<center>
</br></br>
</center>
</form>
</body>
</html>
Mainframe.html
<html>
<head>
<title> frame </title>
</head>
<body>
<center>
<table border="1">
<tr>
</tr>
<tr>
<td>
frame2<ul>
</li>
</li>
</li>
</ul></td>
</td>
</tr>
</table>
</center>
</body>
</html>
Frame1.html
<html>
<body>
</body>
</html>
Frame2.html
<html>
<body>
</html>
Frame3.html
<html>
<body>
</body>
</html>
Q.Write a Javascript to create a pull-down menu with three options [Google, MSBTE,
Yahoo] once the user will select one of the options then user will be redirected to that
site.
<html>
<head>
</head>
<title></title>
function getPage(choice)
page=choice.options[choice.selectedIndex].value;
if(page!="")
window.location=page;
</script>
<body>
<option value="https://www.google.com">GOOGLE</option>
<option value="https://www.msbte.com">MSBTE</option>
<option value="https://www.yahoo.com">YAHOO</option>
</form>
</body>
</html>
Output
Q. Fibbonacci Series :
<html>
<script>
function fibbo(num)
{
var n=0;
var n1=1;
var i=0;
var temp;
for(i=0;i<num;i++)
temp=n+n1;
n=n1;
n1=temp;
return n1;
</script>
</html>
Winter-22
<html>
<head>
<title>Palindrome</title>
</head>
<script>
function display(str)
var len=str.length;
var flag=1;
for(var i=0;i<len/2;i++)
if(str[i] !==str[len-1-i])
flag=0;
if(flag==1)
document.write("it is a palindrome");
else
</script>
</html>
Output:-
Q.5}B)Develop javascript to convert the given string character to unicode and vice-
versa – 6 marks
<html>
<head>
<title>String demo</title>
</head>
<script>
document.write("<br>Unicode="+String.fromCharCode(115));
document.write("<br>Unicode="+String.fromCharCode(70,71,72,115));
</script>
</html>
Output:-
Q.5)C) Write a javscript to create a slideshow with the group of six images, also
simulate the next and previous transition between slides in your js
<html>
<head>
<title> Slideshow</title>
<Script>
img_array=new Array('google.png','apple.png','msbte.jpeg');
img=0;
function DisplayImg(num)
img=img+num;
if(img>img_array.length-1)
img=0;
if(img<0)
img=img_array.length-1;
document.Slide.src=img_array[img];
</script>
</head>
<body>
<br><br>
<input type="button" value="privious" onclick="DisplayImg(-1)">
</body>
</html>
Output:-
Q. Write a html code to design a form that display two textboxes for accepting two
numbers , one textbox for accepting result and two buttons as addition and
subtraction.
<html>
<head>
<title>Arithmetic operation</title>
<script>
function addition()
var a=document.getElementById("t1").value;
var b=document.getElementById("t2").value;
var sum=parseInt(a)+parseInt(b);
document.getElementById("t3").value=sum;
}
function subtraction()
var a=document.getElementById("t1").value;
var b=document.getElementById("t2").value;
var diff=parseInt(a)-parseInt(b);
document.getElementById("t3").value=diff;
</script>
<body>
</body>
</head>
</html>
o/p:
Q. Write a html code to design a form that displays two buttons START and STOP .
write a javascript code such that when user clicks on start button , real time digital
clock will be displayed on screen. When user clicks on stop button ,clock will stop
dislaying time.(use timer method)
<!DOCTYPE html>
<html>
<head>
<title>Digital Clock</title>
</head>
<script>
function updateClock()
hours -= 12;
meridiem = "PM";
if (hours === 0)
hours = 12;
var time = hours + ":" + minutes + ":" + seconds + " " + meridiem;
document.getElementById("clockDisplay").innerHTML = time;
setInterval(updateClock, 1000);
function stopClock()
setTimeout(display,1000);
function display()
alert("time out");
</script>
<body>
<p id="clockDisplay"></p>
</body>
</html>
o/p:
<html>
<head>
<title>radio button</title>
</head>
<script>
function displayList(eleval)
with(document.forms.frm1)
if(eleval==1)
op1[0].text="wpd"
op1[0].value="1"
op1[1].text="pic"
op1[1].value="2"
op1[2].text="maths"
op1[2].value="3"
if(eleval==2)
{
op1[0].text="oop"
op1[0].value="1"
op1[1].text="dsu"
op1[1].value="2"
op1[2].text="dbms"
op1[2].value="3"
</script>
</head>
<body>
<option value=1>WPD
<option value=2>PIC
<option value=3>MATHS
</select>
</body>
</html>
Protection web page
<html>
<head>
<script>
function RightClickDisable()
return false;
function InternetExploreBrowser()
if(event.button==2)
RightClickDisable();
return false;
</script>
</head>
<body>
</body>
</html>
Folding Trees menu
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
ul {
list-style: none;
padding-left: 20px;
}
li {
cursor: pointer;
}
</style>
<title>Folding Tree Menu</title>
</head>
<body>
<ul id="tree">
<li>Root
<ul>
<li>Child 1</li>
<li>Child 2
<ul>
<li>Grandchild 1</li>
<li>Grandchild 2</li>
</ul>
</li>
<li>Child 3</li>
</ul>
</li>
</ul>
<script>
document.addEventListener('DOMContentLoaded', function () {
const tree = document.getElementById('tree');
</body>
</html>