求一段js代码,实现网上答题,有很多道选择题,每选择一题,在跟随页面的答题卡上有相应的标记
展开全部
我帮你实现了,直接copy下面的代码进行测试吧。
————————————————————————————————
<html>
<head>
<style type="text/css">
.opt{
width:20px;
height:20px;
border:1px solid gray;
float:left;
}
.opt_later{
width:20px;
height:20px;
border:1px solid gray;
float:left;
background-color:gray;
}
</style>
</head>
<body>
<form>
<fieldset id="fieldset1">
<p>1:which one do you like to do?</p>
<input type="radio" name="timu1"value="a" onclick="fun('div1')" />(a):fuck<br />
<input type="radio" name="timu1" value="b" onclick="fun('div1')" />(b):shit<br />
<input type="radio" name="timu1" value="c" onclick="fun('div1')" />(c):made<br />
<input type="radio" name="timu1" value="d" onclick="fun('div1')" />(d):cao<br />
</fieldset>
</form>
<form>
<fieldset id="fieldset2">
<p>2:who do you want to fuck?</p>
<input type="radio" name="timu2" value="a" onclick="fun('div2')" />(a):lili<br />
<input type="radio" name="timu2" value="b" onclick="fun('div2')" />(b):lusi<br />
<input type="radio" name="timu2" value="c" onclick="fun('div2')" />(c):ruby<br />
<input type="radio" name="timu2" value="d" onclick="fun('div2')" />(d):java<br />
</fieldset>
</form>
<form>
<fieldset id="fieldset3">
<p>3:where do you like to go?</p>
<input type="radio" name="timu3" value="a" onclick="fun('div3')" />(a):sisiter's room<br />
<input type="radio" name="timu3" value="b" onclick="fun('div3')" />(b):classroom<br />
<input type="radio" name="timu3" value="c" onclick="fun('div3')" />(c):bathroom<br />
<input type="radio" name="timu3" value="d" onclick="fun('div3')" />(d):bedroom<br />
</fieldset>
</form>
<div>
<p>datika:(note:the boxes which are gray color filled is indicate that the related questions are answered)</p>
<div class="opt" id="div1">1</div>
<div class="opt" id="div2">2</div>
<div class="opt" id="div3">3</div>
</div>
<script type="text/javascript">
function fun(a){
var x=document.getElementById(a);
x.className="opt_later";
}
</script>
</body>
</html>
——————————————————————————————
————————————————————————————————
<html>
<head>
<style type="text/css">
.opt{
width:20px;
height:20px;
border:1px solid gray;
float:left;
}
.opt_later{
width:20px;
height:20px;
border:1px solid gray;
float:left;
background-color:gray;
}
</style>
</head>
<body>
<form>
<fieldset id="fieldset1">
<p>1:which one do you like to do?</p>
<input type="radio" name="timu1"value="a" onclick="fun('div1')" />(a):fuck<br />
<input type="radio" name="timu1" value="b" onclick="fun('div1')" />(b):shit<br />
<input type="radio" name="timu1" value="c" onclick="fun('div1')" />(c):made<br />
<input type="radio" name="timu1" value="d" onclick="fun('div1')" />(d):cao<br />
</fieldset>
</form>
<form>
<fieldset id="fieldset2">
<p>2:who do you want to fuck?</p>
<input type="radio" name="timu2" value="a" onclick="fun('div2')" />(a):lili<br />
<input type="radio" name="timu2" value="b" onclick="fun('div2')" />(b):lusi<br />
<input type="radio" name="timu2" value="c" onclick="fun('div2')" />(c):ruby<br />
<input type="radio" name="timu2" value="d" onclick="fun('div2')" />(d):java<br />
</fieldset>
</form>
<form>
<fieldset id="fieldset3">
<p>3:where do you like to go?</p>
<input type="radio" name="timu3" value="a" onclick="fun('div3')" />(a):sisiter's room<br />
<input type="radio" name="timu3" value="b" onclick="fun('div3')" />(b):classroom<br />
<input type="radio" name="timu3" value="c" onclick="fun('div3')" />(c):bathroom<br />
<input type="radio" name="timu3" value="d" onclick="fun('div3')" />(d):bedroom<br />
</fieldset>
</form>
<div>
<p>datika:(note:the boxes which are gray color filled is indicate that the related questions are answered)</p>
<div class="opt" id="div1">1</div>
<div class="opt" id="div2">2</div>
<div class="opt" id="div3">3</div>
</div>
<script type="text/javascript">
function fun(a){
var x=document.getElementById(a);
x.className="opt_later";
}
</script>
</body>
</html>
——————————————————————————————
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询