pthompson2002
08-23-2002, 01:30 PM
Could anyone tell me if and how it is possilbe to return the character position within a <textarea> When either moving the arrow keys, and clicking anywhere within the textarea with the mouse?
Cheers Pete
Here is the code I have currently, this just returns the currentcharacter position as you type.
NOTE: the submit button doesn't do anything. It is just there for layout purposes at the moment
-------------------------------------------------
<BODY>
<form method="POST">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" colspan="2">
<textarea rows="12" name="charcount" onkeyup="return countit(this)" cols="60" wrap="virtual"></textarea>
</td>
</tr>
<tr>
<td valign="top" width="35%">Current Character Position:</td>
<td><div id="displaycount" size="20"> </div></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td align=left><input type="submit" name="submitMsg" value="Submit"></td>
</tr>
</table>
</form>
<script language="JavaScript">
function countit(what){
formcontent=what.form.charcount.value
displaycount.innerHTML=formcontent.length
}
</script>
</BODY>
Cheers Pete
Here is the code I have currently, this just returns the currentcharacter position as you type.
NOTE: the submit button doesn't do anything. It is just there for layout purposes at the moment
-------------------------------------------------
<BODY>
<form method="POST">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" colspan="2">
<textarea rows="12" name="charcount" onkeyup="return countit(this)" cols="60" wrap="virtual"></textarea>
</td>
</tr>
<tr>
<td valign="top" width="35%">Current Character Position:</td>
<td><div id="displaycount" size="20"> </div></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td align=left><input type="submit" name="submitMsg" value="Submit"></td>
</tr>
</table>
</form>
<script language="JavaScript">
function countit(what){
formcontent=what.form.charcount.value
displaycount.innerHTML=formcontent.length
}
</script>
</BODY>