Page 1 of 1

returning undefined while retrieving value of textarea

Posted: Wed Aug 22, 2007 4:41 pm
by raghavan20
i have a form which has a textarea, 'bookdetails'. on submit, i want to get the value in the text area. i have a script below which works fine in Mozilla firefox but not on IE. I am getting crazy with this; please advise.

Code: Select all

<script type = 'text/javascript'>
	function reportErrorOnBookDetails( ){
		alert(document.getElementById('bookDetails').value);
	}

</script>

				<div id = "bookDetailsResponse"></div>
				<table width="100%" border="0" class="content_alltables" cellspacing="0" cellpadding="0">
					<tr>
						<td height="25" colspan="3" class="ErrorForm">
						<a name="BookDetails">Book Details</a></td>
					</tr>
					<tr>
						<td>
							<div class="textContent_lineSpace">
								<strong>Please specify the exact nature of the error</strong>
							</div>
						</td>
					</tr>
					<tr>
						<td class="textContent_lineSpace">
						<input type="checkbox" name="title" id = "title" value="title">
						Title<br>
						<input type="checkbox" name="authorName"  id="authorName" value="authorName"> 
						Author Name <br>
						<input type="checkbox" name="publishDate" id="publishDate"  value="publishDate"> 
						Publish Date <br>
						<input type="checkbox" name="other"  id="other" value="other"> Other
						</td>
					</tr>
					<tr>
						<td>
							<div class="textContent_lineSpace">
								<strong>Please provide some details about the error</strong>
							</div>
						</td>
					</tr>
					<tr>
						<td class="textContent_lineSpace">
						<textarea name="bookDetails" id = "bookDetails" cols="60" rows="5" style="width: 400px; height: 100px"></textarea>
						</td>
					</tr>
					<tr>
						<td class="textContent_lineSpace">

							<table>
								<tr>
									<td colspan = "2">
										<input type="hidden" id = "productId" name="productId" value="1841150088">
										Please enter the verification code given against the text field below
									</td>
								</tr>
								<tr>
									<td class = "lAlign" width="200"><input type = "text" id = "BDVerificationCode" name = "BDVerificationCode" value = "" />&nbsp;&nbsp;</td>
									<td class = "lAlign"><img id = "BDVerificationImage" src = "http://www.bookdepository.co.uk/Modules/Captcha/images/2292_1187816718.jpg"   />&nbsp;</td>
								</tr>
								<tr>
									<td colspan = "2">
										<input onclick = "reportErrorOnBookDetails( )" 
										type="image" src="/WEBSITE/WWW/TEMPLATE1/MEDIA/IMAGES/buttons/submit_btn.gif" width="92" height="23" border="0" name="submit_error" value="Submit Error" />
									</td>
								</tr>
							</table>
							
							
						</td>
					</tr>
				</table>

Posted: Wed Aug 22, 2007 4:46 pm
by VladSun
:)
You have an anchor named BookDetails in your HTML ;)

Posted: Wed Aug 22, 2007 5:11 pm
by raghavan20
yes, it was the error. you made me happy. :D