| | |
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 |
acid2 ajax ajaxexample ajaxjspservlets array beta box browser captchaformproblem cart child class close codes column css date debugger decimal dependent design disablefirebug dom download editor element embed engine enter error events explorer ext file firefox focus form forms frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe index java javascript javascripthelp2020 jquery jsf jsp jump libcurl listbox maps masterpage math media menu microsoft mimic mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php position post problem programming prototype redirect safari scale scriptlets scroll search security select software toggle unicode variables w3c web webservice window windowofwords \n





