A Form With Checkboxes: Source Code
A Form With Checkboxes: Source Code
SOURCE CODE:
<!DOCTYPE html>
<html>
<body>
<%fruits=Request.Form("fruits")\%><form action="demo_checkboxes.asp"
method="post">
<p>Which of these fruits do you prefer:</p>
<input type="checkbox" name="fruits" value="Apples"
<%if instr(fruits,"Apple") then Response.Write("checked")%>>
Apple
<br>
<input type="checkbox" name="fruits" value="Oranges"
<%if instr(fruits,"Oranges") then Response.Write("checked")%>>
Orange
<br>
<input type="checkbox" name="fruits" value="Bananas"
<%if instr(fruits,"Banana") then Response.Write("checked")%>>
Banana
<br>
<input type="submit" value="Submit">
</form>
<%if fruits<>"" then%>
A FORM WITH CHECK BOXES
<p>You like: <%Response.Write(fruits)%></p>
<%end if%>
</body>
</html>
OUTPUT:
Which of these fruits do you prefer:
Apple
Orange
Banana
Submit
You like: Bananas
A FORM WITH RADIO BUTTONS
SOURECE CODE:
<!DOCTYPE html>
<html>
<%
dim cars
cars=Request.Form("cars")
%>
<body>
<form action="demo_radiob.asp" method="post">
<p>Please select your favorite car:</p>
\<input type="radio" name="cars"
<%if cars="Volvo" then Response.Write("checked")%>
value="Volvo">Volvo</input>
<br>
<input type="radio" name="cars"
<%if cars="Saab" then Response.Write("checked")%>
value="Saab">Saab</input>
<br>
<input type="radio" name="cars"
<%if cars="BMW" then Response.Write("checked")%>
value="BMW">BMW</input><br><br>
A FORM WITH RADIO BUTTONS
<input type="submit" value="Submit" />
</form>
<%
if cars<>"" then
Response.Write("<p>Your favorite car is: " & cars & "</p>")
end if
%>
</body>
</html>
OUTPUT:
Please select your favorite car:
Volvo
Saab
BMW
Submit
Your favorite car is: BMW
A CLOCK CREATED WITH A
TIMING EVENT
SOURCE CODE:
<!DOCTYPE html>
<html>
<head>
<script>
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10
m=checkTime(m);
s=checkTime(s);
document.getElementById('txt').innerHTML=h+":"+m+":"+s;
t=setTimeout(function(){startTime()},500);
}
function checkTime(i)
{
A CLOCK CREATED WITH A
TIMING EVENT
if (i<10)
{
i="0" + i;
}
return i;
}
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
</body>
</html>
OUTPUT:
9:32:12
STOP CLOCK
SOURCE CODE:
<!DOCTYPE html>
<html>
<head>
<script>
var c=0;
var t;
var timer_is_on=0;
function timedCount()
{
document.getElementById('txt').value=c;
c=c+1;
t=setTimeout(function(){timedCount()},1000);
}
function doTimer()
{
if (!timer_is_on)
{
timer_is_on=1;
timedCount();
}
STOP CLOCK
}
function stopCount()
{
clearTimeout(t);
timer_is_on=0;
}
</script>
</head>
<body>
<form>
<input type="button" value="Start count!" onclick="doTimer()" />
<input type="text" id="txt" />
<input type="button" value="Stop count!" onclick="stopCount()" />
</form>
<p>
Click on the "Start count!" button above to start the timer. The input field will count forever, starting at
0. Click on the "Stop count!" button to stop the counting. Click on the "Start count!" button to start the
timer again.
</p>
</body>
</html>
STOP CLOCK
OUTPUT: