jalaladdin
Active Member
چگونه میتوان با جاوا اسکریپت آزمون تستی طراحی کرد
<html dir="rtl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<p dir="ltr">
<script>
function showResult(QNum){
var result=0;
for(i=0;i<QNum+1;i++){
var all=new Array();
all=document.getElementsByName('Q'+i);
for(j=0;j<all.length;j++){
if(all[j].checked&&all[j].value=='true'){
result+=1;
}
}
}
document.getElementById('result').innerText='YourResult:'+result;
}
function uncheck(name){
var all=new Array();
all=document.getElementsByName(name);
for(i=0;i<all.length;i++){
all[i].checked=false;
}
}
</script>
soal1:matne soal<br />gozine1:<input type="checkbox" name="Q1" value="true" onclick='uncheck(this.name);this.checked=true;'>
gozine2:<input type="checkbox" name="Q1" value="false" onclick='uncheck(this.name);this.checked=true;'>
gozine3:<input type="checkbox" name="Q1" value="false" onclick='uncheck(this.name);this.checked=true;'>
gozine4:<input type="checkbox" name="Q1" value="false" onclick='uncheck(this.name);this.checked=true;'>
<br />//------------------------------------------------------------------------------------------------------------\\<br/>
soal2:matne soal<br />gozine1:<input type="checkbox" name="Q2" value="false" onclick='uncheck(this.name);this.checked=true;'>
gozine2:<input type="checkbox" name="Q2" value="false" onclick='uncheck(this.name);this.checked=true;'>
gozine3:<input type="checkbox" name="Q2" value="true" onclick='uncheck(this.name);this.checked=true;'>
gozine4:<input type="checkbox" name="Q2" value="false" onclick='uncheck(this.name);this.checked=true;'>
</p>
<p dir="ltr">
<input type="submit" value="Submit" name="B1" onclick='showResult(2)'><div id=result></div>
</p>
</body>
</html>
<html dir="rtl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<p dir="ltr">
<script>
function showResult(QNum){
var result=0;
for(i=0;i<QNum+1;i++){
var all=new Array();
all=document.getElementsByName('Q'+i);
for(j=0;j<all.length;j++){
if(all[j].checked&&all[j].value=='true'){
result+=1;
}
}
}
[COLOR="Red"] result=Math.round((result/QNum)*100);[/COLOR]
document.getElementById('result').innerText='YourResult:'+result+'%';
}
function uncheck(name){
var all=new Array();
all=document.getElementsByName(name);
for(i=0;i<all.length;i++){
all[i].checked=false;
}
}
</script>
soal1:matne soal<br />gozine1:<input type="checkbox" name="Q1" value="true" onclick='uncheck(this.name);this.checked=true;'>
gozine2:<input type="checkbox" name="Q1" value="false" onclick='uncheck(this.name);this.checked=true;'>
gozine3:<input type="checkbox" name="Q1" value="false" onclick='uncheck(this.name);this.checked=true;'>
gozine4:<input type="checkbox" name="Q1" value="false" onclick='uncheck(this.name);this.checked=true;'>
<br />//------------------------------------------------------------------------------------------------------------\\<br/>
soal2:matne soal<br />gozine1:<input type="checkbox" name="Q2" value="false" onclick='uncheck(this.name);this.checked=true;'>
gozine2:<input type="checkbox" name="Q2" value="false" onclick='uncheck(this.name);this.checked=true;'>
gozine3:<input type="checkbox" name="Q2" value="true" onclick='uncheck(this.name);this.checked=true;'>
gozine4:<input type="checkbox" name="Q2" value="false" onclick='uncheck(this.name);this.checked=true;'>
[COLOR="Red"]<br />//------------------------------------------------------------------------------------------------------------\\<br/>
soal3:matne soal<br />gozine1:<input type="checkbox" name="[COLOR="Lime"]Q3[/COLOR]" value="false" onclick='uncheck(this.name);this.checked=true;'>
gozine2:<input type="checkbox" name="[COLOR="Lime"]Q3[/COLOR]" value="false" onclick='uncheck(this.name);this.checked=true;'>
gozine3:<input type="checkbox" name="[COLOR="Lime"]Q3[/COLOR]" value="true" onclick='uncheck(this.name);this.checked=true;'>
gozine4:<input type="checkbox" name="[COLOR="Lime"]Q3[/COLOR]" value="false" onclick='uncheck(this.name);this.checked=true;'>
[/COLOR]
</p>
<p dir="ltr">
<input type="submit" value="Submit" name="B1" onclick='showResult[COLOR="Red"](3[/COLOR])'><div id=result></div>
</p>
</body>
</html>
<p>
<table border='0' width='50%' cellspacing='0' cellpadding='0' ><form name=form1 method=post action="quizhtml2.html" onsubmit='return validate(this)'> <tr bgcolor='#ffffff'><td align=center ><font face='verdana' size='2' ><div class=" dir container-content-sidebar-front "><b>1-كداميك از مقادير زير ويژه صفت Align براي تنظيم تصوير در صفحه نمي باشد ؟ </b><br>
<input type=radio name=q value='1' onClick="validate(this)";>left<br>
<input type=radio name=q value='2' onClick="validate(this)";>top<br>
<input type=radio name=q value='3' onClick="validate(this)";>right<br>
<input type=radio name=q value='4' onClick="validate(this)";>center<br>
<br>
<div class=" dir "><b>2-كداميك از مقادير زير ويژه صفت Align براي تنظيم تصوير در صفحه نمي باشد ؟ </b><br>
<input type=radio name=q value='1' onClick="validate(this)";>left<br>
<input type=radio name=q value='2' onClick="validate(this)";>top<br>
<input type=radio name=q value='3' onClick="validate(this)";>right<br>
<input type=radio name=q value='4' onClick="validate(this)";>center<br>
<br>
<div class=" dir "><b>3-كداميك از مقادير زير ويژه صفت Align براي تنظيم تصوير در صفحه نمي باشد ؟ </b><br>
<input type=radio name=q value='1' onClick="validate(this)";>left<br>
<input type=radio name=q value='2' onClick="validate(this)";>top<br>
<input type=radio name=q value='3' onClick="validate(this)";>right<br>
<input type=radio name=q value='4' onClick="validate(this)";>center<br>
<br>
<div class=" dir "><b>4-كداميك از مقادير زير ويژه صفت Align براي تنظيم تصوير در صفحه نمي باشد ؟ </b><br>
<input type=radio name=q value='1' onClick="validate(this)";>left<br>
<input type=radio name=q value='2' onClick="validate(this)";>top<br>
<input type=radio name=q value='3' onClick="validate(this)";>right<br>
<input type=radio name=q value='4' onClick="validate(this)";>center<br>
<br>
<div class=" dir "><b>5-كداميك از مقادير زير ويژه صفت Align براي تنظيم تصوير در صفحه نمي باشد ؟ </b><br>
<input type=radio name=q value='1' onClick="validate(this)";>left<br>
<input type=radio name=q value='2' onClick="validate(this)";>top<br>
<input type=radio name=q value='3' onClick="validate(this)";>right<br>
<input type=radio name=q value='4' onClick="validate(this)";>center<br>
<br>
<input type=submit value=بعدی> <input type=reset value=Reset></td></tr></div>
</table></form>
</p>