根據所選選項的類型,我希望顯示1或3個文本區域,即 如果選擇選項「mc」,我希望顯示3個文本區域。 我正在嘗試在Javascript中執行此操作,但是3個文本區域都顯示了所選的每個選項。我認爲JS功能不起作用。請讓我知道錯誤在哪裏。如何根據條件選擇文本區域的數量
謝謝。
代碼:
<head>
<link href="./css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h:form>
<script type="text/javascript">
function selectans(qtype) {
if (qtype == "mc")
{
alert("In MC type");
document.getElementById("formId:editor3").style.display = "block";
document.getElementById("formId:editor4").style.display = "block";
//document.form.editor3.disabled = false;
//document.form.editor4.disabled = false;
}
else {
document.getElementById("formId:editor3").style.display = "none";
document.getElementById("formId:editor4").style.display = "none";
//document.form.editor3.disabled = true;
//document.form.editor4.disabled = true;
}
}
</script>
Question Type:
<h:selectOneMenu id="qtype" value ="#{quizBean.qtype}" onchange="selectans(qtype) ">
<f:selectItem id="desc" itemLabel="Descriptive Type" itemValue="desc" />
<f:selectItem id="fill" itemLabel="Fill up the Blanks" itemValue="fill" />
<f:selectItem id="mc" itemLabel="Multiple Choice" itemValue="mc" />
<f:selectItem id="tf" itemLabel="True/False" itemValue="tf" />
</h:selectOneMenu>
Question: <h:inputTextarea id="editor1" value="#{quizBean.question}" rows="20" cols="75" /> <br></br>
Answer:
<h:inputText id ="editor2" value="#{quizBean.answerChoice2}" />
<h:inputText id ="editor3" value="#{quizBean.answerChoice2}" />
<h:inputText id ="editor4" value="#{quizBean.answerChoice3}" />
<h:commandButton value="Submit" action="#{quizBean.addQuestion}" />
</h:form>
</body>
CSS:
root {
display: block;
}
.hide {
display: none;
}
外接顯示器通過:無屬性,加載時只顯示第一個textarea框,然後點擊調用其他textare a基於點擊 – EnterJQ 2013-02-19 05:43:04
我在CSS中添加了display:none屬性,並且鏈接了html的頭部的css – Shilpa 2013-02-19 05:57:30