HTML+JS Survey page presentation and form submission

Source: Internet
Author: User

From the database to find the type of problem, select the type to show the sub-problem of this kind, multi-select, click to deselect

Sub-Problem:

When the option is selectable, the input box disappears when the input box appears and the other option is clicked.

HTML section:

<body >
<div data-role= "Page" >
<div data-role= "Header"
Style= "border:0; Background: #FBCDCA; Text-align:center; height:55px; " >
<div style= "PADDING-TOP:3PX;" >
<p>
<b> Questionnaires </b>
</p>
</div>

</div>
<div data-role= "main" id= "main" >
<div id= "outer" >
<form onsubmit= "return check ()" action= "Savequestionnairersponse" method= "POST" >
<div class= "Type" >
<div class= "Question" >
Please select the type of question you want to investigate:
</div>
<div class= "Answer" >
<c:foreach var= "type" items= "${typelist}" varstatus= "status" >
<input type= "Radio" onclick= "Showchild (This,${status.index})"/>${type.qtname}<br/>
</c:forEach>
</div>
</div>
<c:foreach var= "type" items= "${typelist}" varstatus= "status" >
<div id= "Type${status.index}" style= "Display:none;" >
<c:foreach var= "question" items= "${questionlist}" varstatus= "Q" >
<c:if test= "${question.qtid = = Type.qtid}" >
<div class= "Question" >
${question.questioncontent}
</div>
<div class= "Answer" id= "Answer${q.index}" >
<c:foreach var= "option" items= "${optionlist}" varstatus= "S" >
<c:if test= "${option.tquestioninfo.questionid = = Question.questionid}" >
<input type= "Radio" id= "Op${s.index}" name= "Questionnairersponse[${q.index}].tquestionoptionsinfo.optionid" Value= "${option.optionid}" class= "option" onchange= "Change (${q.index})"/>${option.optioncontent}<br/>
<div >
<c:if test= "${option.iswrite==1}" >
<div id= "Table${s.index}" style= "Display:none" >
<table
style= "border-bottom:1px solid green; width:80% "
cellpadding= "0" cellspacing= "0" >
<tr>
<td>
<input type= "text" style= "border:0; Background: #FEFCC8; width:100%; "
Name= "Questionnairersponse[${q.index}].writecontent" id= "Write${s.index}"/>
</td>
</tr>
</table>
</div>
</c:if>
</div>
</c:if>
</c:forEach>
</div>
</c:if>
</c:forEach>

</div>
</c:forEach>

<div style= "margin-top:20px;" >
<input type= "Submit" value= "Submission Questionnaire" style= "Background-color: #FBCDCA; border:0"/>
</div>

</form>


</div>
</div>


</div>
</body>

JS section:


<script type= "Text/javascript" >
var length = "${fn:length (typelist)}";
var questionlength = "${fn:length (questionlist)}";
var optionlength = "${fn:length (optionlist)}";
var tempradio = new Array ();
function Showchild (Checkedradio, index) {
for (var i = 0; i < length; i++) {
if (index = = i) {
var subquestion = "type" + i;
if (tempradio[i] = = Checkedradio) {
checkedradio.checked = false;
document.getElementById (subquestion). Style.display = "None";
Tempradio[i] = null;

} else {
document.getElementById (subquestion). style.display = "block";
Tempradio[i] = Checkedradio;
}
}
}
}

function Change (Answerid) {
var QuestionID = "Answer" + answerid;
var v = document.getElementById (QuestionID). getElementsByTagName ("input");
for (var i = 0; i < v.length; i++) {
if (V.item (i). Checked) {
var inputID = V.item (i). ID;
var tableId = "Table" + inputid.substring (2, 3);
var writetable = document.getElementById (tableId);
if (writetable! = null) {
WriteTable.style.display = "block";

}
for (var j = 0; J < V.length; J + +) {
if (i! = j) {
var inputID = V.item (j). ID;
var Writeid = "Write" + inputid.substring (2, 3);
var writetext = document.getElementById (Writeid);
if (WRITETEXT! = null) {
Writetext.value = "";
}
}
}
} else {
var inputID = V.item (i). ID;
var tableId = "Table" + inputid.substring (2, 3);

var writetable = document.getElementById (tableId);

if (writetable! = null) {
WriteTable.style.display = "None";
}
}
}


}
function Check () {
var sum = 0;
for (var i = 0; i < optionlength; i++) {
var QuestionID = "Op" + i;
var v = document.getElementById (QuestionID);
if (v.checked) {
Sum+=1;
}

}
if (Sum > 0) {
return true;
} else {
return false;
}

}

HTML+JS Survey page presentation and form submission

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.