LelloLello
asked on
Calculate and display the number of characters within a TEXTAREA
I have the following code
<form method="POST">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<textarea rows="12" name="charcount" cols="60" wrap="virtual"></textarea>
</td>
</tr>
<tr>
<td width="100%"><div align="right"><p><input type="button" value="Calculate Characters"
onClick="countit(this)"> <input type="text" name="displaycount" size="20"></p>
<div align="center"><center><p> This free script provided by
<a href="http://javascriptkit.com">JavaScript
Kit</a></p>
</center></div></div></td>
</tr>
</table>
</form>
<script language="JavaScript">
function countit(what){
//Character count script- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
//Credit must stay intact for use
formcontent=what.form.char count.valu e
what.form.displaycount.val ue=formcon tent.lengt h
}
</script>
<form method="POST">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<textarea rows="12" name="charcount" cols="60" wrap="virtual"></textarea>
</td>
</tr>
<tr>
<td width="100%"><div align="right"><p><input type="button" value="Calculate Characters"
onClick="countit(this)"> <input type="text" name="displaycount" size="20"></p>
<div align="center"><center><p>
<a href="http://javascriptkit.com">JavaScript
Kit</a></p>
</center></div></div></td>
</tr>
</table>
</form>
<script language="JavaScript">
function countit(what){
//Character count script- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
//Credit must stay intact for use
formcontent=what.form.char
what.form.displaycount.val
}
</script>
Please check my code sample at http://jsfiddle.net/vMwQ8/
ASKER
Sudaraka,
http://blog.wardelldesign.com/wp-content/uploads/rollover/rollover.html
Very good, One small issue missing could you please add to it a function to have an interactive button with the roll over action and roll out using a button class.
<form method="POST">
<input type="button" value="Calculate Clicks"
onClick="countit(this)">
<input type="text" name="displaycount" size="20">
</form>
function countit(what){
var current_count = parseInt(what.form.display count.valu e);
if(isNaN(current_count)) current_count = 0;
what.form.displaycount.val ue = ++current_count;
}
http://blog.wardelldesign.com/wp-content/uploads/rollover/rollover.html
Very good, One small issue missing could you please add to it a function to have an interactive button with the roll over action and roll out using a button class.
<form method="POST">
<input type="button" value="Calculate Clicks"
onClick="countit(this)">
<input type="text" name="displaycount" size="20">
</form>
function countit(what){
var current_count = parseInt(what.form.display
if(isNaN(current_count)) current_count = 0;
what.form.displaycount.val
}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER