I am trying to set up an Add Question button function but I am off to a bad start. I am receiving a error stating:
TypeError: form.questionText is undefined
What am I doing wrong?
<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>
you have not defined
questionTextanywere so it will giveundefinederrorUpdate 1:
And then you have to add your questionText in the
formwhere your submit button is: