| | |
simple Javascript counting function
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jan 2008
Posts: 62
Reputation:
Solved Threads: 6
Hi, i have a form on my website, and I would like to have a text box next to another text box that displays how many letters the user can type into the box eg:
This is fine, but I would like the box with the numbers in it to count down as the user types in the first box, and if they delete something i would like the number to go back up again too.
If anyone could help me that'd be great thanks.
html Syntax (Toggle Plain Text)
<td><input type="text" name="description" maxlength="30" /></td> <td><input type="text" class="counter" value="30" disabled="true" /></td>
This is fine, but I would like the box with the numbers in it to count down as the user types in the first box, and if they delete something i would like the number to go back up again too.
If anyone could help me that'd be great thanks.
use onkeydown event in text box,
in this event write a function which will take value of textbox check the length of string and then print the no. in the box......
in this event write a function which will take value of textbox check the length of string and then print the no. in the box......
Freedom in the Mind, Faith in the words.. Pride in our Souls...
Indian Developer
http://falaque.wordpress.com/
Indian Developer
http://falaque.wordpress.com/
Hi There,
Try This Code
JavaScript:
HTML:
Rahul Dev Katarey
Try This Code
JavaScript:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<script type="text/javascript"> function valueChange(){ textBox1 = document.getElementById('textBox1'); description = document.getElementById('description'); textBox1.value = description.value.length; } </script>
HTML:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<input type="text" name="description" maxlength="30" id="description" onkeyup="valueChange()" /></td> <input type="text" class="counter" readonly="readonly" id="textBox1" />
Rahul Dev Katarey
Last edited by katarey; Feb 20th, 2008 at 2:16 pm.
![]() |
Similar Threads
- CSS pseudo-letter ??? (HTML and CSS)
Other Threads in the JavaScript / DHTML / AJAX Forum
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
acid2 ajax ajaxcode ajaxhelp animate api array automatically beta boarder box bug calendar captcha card cart checkbox class codes column cookies createrange() css cursor decimal design dom download dropdown element enter error events explorer firefox firehose focus form frameworks google gwt html htmlform iframe image() images index internet java javascript javascripts jawascriptruntimeerror jquery jsf jsfile jsp listbox marquee masterpage matrixcaptcha menu microsoft mimic mp4 object onmouseover parameters passing php player post problem progressbar prototype rating redirect regex runtime scale search select session shopping size sources sql starrating stars text textarea toggle twitter validation w3c website window windowofwords windowsxp wysiwyg xml





