<html>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<head>
<title></title>
</head>
<body>
<form name="form1" method="post" action="">
添加问题:<br><input type="text" name="question" /><br>
添加答案选项:<br><textarea name="content" cols="30" rows="5"></textarea>
<br/>
<span style="color:red;font-size:10px">答案之间请用*区隔</span>
<br>
<input type="button" name="submit" value="提交"/>
</form>
<?php
?>
<script language="javascript">
var forms=document.forms[0];
var input=forms.elements['question'];
var content=forms.elements['content'];
var button=forms.elements['submit'];
var div=document.createElement("div");
button.onclick=function(){
this.disabled=true;
var inputvalue=input.value;
var contentvalue=content.value;
if(inputvalue != '' && contentvalue != ''){
var title=document.createElement('h4');
title.innerHTML="问题:"+inputvalue;
div.appendChild(title);
var re=contentvalue.split("*");
for(var i in re){
var checkbox=document.createElement('input');
checkbox.type="checkbox";
checkbox.name="checkbox";
checkbox.value=i;
var span=document.createElement('span');
span.innerHTML=re[i];
div.appendChild(checkbox);
div.appendChild(span);
}
document.body.appendChild(div);
}
}
</script>
</body>
</html>
|