javascript character count not working
Posted: Sat Aug 02, 2003 3:30 pm
is this me using the wrong functions or is it something else causing this not to work... whille the code is prepped for a php file, it's actually from an html file i whipped up to get the javascript right so i know any future issues are either with php or the db
note: i'd prefer to get the first working
and the variation i made thinking maybe i could moorph it a bit to look like something else i made that does work....
note: i'd prefer to get the first working
Code: Select all
<html><head></head><body><center>
<form action="<?php echo $_SERVERїPHP_SELF]; ?>" name="new_friend" method="POST" onReset="window.close();">
<table frame="void" bgcolor="#000000" border="0" cellpadding="0" cellspacing="0" text="#c8c8c8">
<tr>
<td>Selected Friend</td>
<td><input type="text" name="fun" readonly size="15" value="<?php echo $_GETї'un']; ?>"></td>
</tr>
<tr>
<td colspan="2">
<textarea cols="30" name="cof" onKeyUp="return findlength();" rows="4" wrap="virtual">
Enter a Comment or clear this. You have a maximum of 255 characters, everything above that will be lost
</textarea>
</td>
</tr>
<tr><td colspan="2">Characters in Comment:<input type="text" name="chars" readonly size="3" value="0"></td>></tr>
<tr>
<td><input type="submit" value="Add My Friend!"></td>
<td><input type="reset" value="Not My Friend"></td>
</tr>
</table>
</form>
<script language="javascript">
function findlength(){
var comment=document.new_friend.cof.value(); // get the comment
var numchars=comment.length; // find the number of characters
document.new_friend.chars.write(numchars); // let the user know the number of characters
}
</script>
</center>
</body>
</html>Code: Select all
<html><head></head><body><center>
<form action="<?php echo $_SERVERїPHP_SELF]; ?>" name="new_friend" method="POST" onReset="window.close();">
<table frame="void" bgcolor="#000000" border="0" cellpadding="0" cellspacing="0" text="#c8c8c8">
<tr>
<td>Selected Friend</td>
<td><input type="text" name="fun" readonly size="15" value="<?php echo $_GETї'un']; ?>"></td>
</tr>
<tr>
<td colspan="2">
<textarea cols="30" name="cof" onKeyUp="return findlength();" rows="4" wrap="virtual">
Enter a Comment or clear this. You have a maximum of 255 characters, everything above that will be lost
</textarea>
</td>
</tr>
<tr><td colspan="2"><iframe name="chars" src="chars.html"></iframe></td></tr>
<tr>
<td><input type="submit" value="Add My Friend!"></td>
<td><input type="reset" value="Not My Friend"></td>
</tr>
</table>
</form>
<script language="javascript">
function findlength(){
var comment=document.new_friend.cof.value(); // get the comment
var numchars=comment.length; // find the number of characters used
parent.chars.document.open();
parent.chars.document.write("<html><body>Your comment is "+numchars+" long.</body></html>"); // tell the user the number of character used
parent.chars.document.close();
}
</script>
</center>
</body>
</html>