character counter

H

HandersonVA

Please take a look at the code. The strange thing is.. when I put a
mouse on this field, it starts on 4 spaces after. And the character
number that I set shows "252" instead of "256" automatically. do you
know why? It has to be 256 and first staring mouse point must be the
first position.

<head>
<title>Blank Form</title>
<link rel="stylesheet" type="text/css"
href="../common/newcodestyle.css" />

<script type="text/javascript">
<!-- Character Coutner -->
<!-- Begin
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
{field.value = field.value.substring(0, maxlimit);}
else
{countfield.value = maxlimit - field.value.length;}
}
// End -->
</script>
</head>

<table>
<tr>
<td align="right" valign="top">Justification:</td>
<td align="left"><cfoutput>
<textarea name="justification" rows="7" cols="40" wrap="soft"
onKeyDown="textCounter(this.form.justification,this.form.remLentext,256);"
onKeyUp="textCounter(this.form.justification,this.form.remLentext,256);">
</textarea></cfoutput>
<input type="box" readonly="readonly" name="remLentext" size="3"
value="256" />
</td>
</tr>
</table>
 
P

Papajo

As far as your cursor alignment goes the closing textarea tag has to be
right after the opening tag, no spaces.
<textarea cols="" rows=""></textarea>
 
W

web.dev

HandersonVA said:
<td align="left"><cfoutput>

We don't need to see coldfusion tags. It's usually more relevant to
show what the client will see instead.
<textarea name="justification" rows="7" cols="40" wrap="soft"
onKeyDown="textCounter(this.form.justification,this.form.remLentext,256);"
onKeyUp="textCounter(this.form.justification,this.form.remLentext,256);">
</textarea></cfoutput>

As for the 4 spaces in your textarea, user agens should use the
contents of this element as the initial value of the control and should
render this text initially. So if there are any spaces in between your
textarea tags, remove them.

Secondly, you are sending this.form.justification and
this.form.remLentext to your function. However your parameters are
incorrect in that, how can you make reference to your form elements
when they are not in a form themselves? For example:

<form name = "myForm" action = "proc.cfm">
<text area name = "justification"></textarea>
</form>

And typically, referencing forms and its elements are easier (a matter
of opinion) through the use of square bracket notation. Like so:

document.forms["myForm"].elements["justification"];
 
V

VA Handerson

oh there are still cf codes in it. I thought I removed them before I
posted. Anyway, the problem was a space. I removed the sapce b/w the
textare end tag before the value.
thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top