Breaking

Post Top Ad

Your Ad Spot

मंगलवार, 17 मार्च 2015

Fieldset example

<! Doctype html>
<html>
<head>

</head>
<body>

<form>
<fieldset> <legend> quiz</legend>

Q.1. Which city called pink city ? <br>

<input type = "radio" name = "q1" value = " jay" CHECKED > jaypur
<br>
<input type = "radio" name = "q1" value = " uda" CHECKED > Udaipur
<br>
<input type = "radio" name = "q1" value = "bna" CHECKED> bnarash
<br>

Q.2. The first president of india? <br>
<input type = "radio" name = "q2" value = " nehru" CHECKED > nehru
<br>
<input type = "radio" name = "q2" value = " rajendra" CHECKED > R Prasad
<br>
<input type = "radio" name = "q2" value = " gandhi" CHECKED > gandhi

<input type="button" value="result" onclick="finalresult()">

</fieldset>
</form>

<script Language ="text/JavaScript">

function finalresult()
{
//variables with global implications

var totalQuestions = 2;
var correctAnswers = 0;
var alertText;
var i;

var a1 =
document.getElementsByName
('q1');
for(i = 0; i < a1.length; i
++)
{
if(a1[i].checked)
{
if
(a1[i].value == 'jay')
{
correctAnswers++;
break;
}
}
}

var a2 =
document.getElementsByName
('q2');
for(i = 0; i < a2.length; i
++)
{
if(a2[i].checked)
{
if
(a2[i].value == 'rajendra')
{
correctAnswers++;
break;
}
}
}

document.write(" correct ans are + correctAnswers");

}

</script>

</body>
</html>

कोई टिप्पणी नहीं:

एक टिप्पणी भेजें

Post Top Ad

Your Ad Spot

Pages