我正在尝试设置Add Question
按钮功能,但我的开始很糟糕。我收到一条错误消息:
类型错误:form.questionText 未定义
我究竟做错了什么?
<script type="text/javascript">
function insertQuestion(form) {
var questionarea = (form.questionText.length) ? form.questionText[0] : form.questionText;
}
</script>
<table id="question">
<tr>
<td>Question:</td>
<td>
<textarea class="questionTextArea" id="mainTextarea" rows="5" cols="40" name="questionText"></textarea>
</td>
</tr>
</table>
<form id="QandA" action="insertQuestion.php" method="post">
<table id="questionBtn" align="center">
<tr>
<th>
<input id="addQuestionBtn" name="addQuestion" type="button" value="Add Question"
onClick="insertQuestion(this.form)" />
</th>
</tr>
</table>
</div>
<hr/>
<table id="qandatbl" align="center" cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
<th width="13%" class="question">Question</th>
</tr>
</thead>
</table>
<div id="qandatbl_onthefly_container">
<table id="qandatbl_onthefly" align="center" cellpadding="0" cellspacing="0"
border="0">
<tbody></tbody>
</table>
</div>
</form>