School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,574 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,193 people online right now. Registration is fast and FREE... Join Now!




'remaining chars count' not working (of course)

 

'remaining chars count' not working (of course)

livium

27 Jun, 2009 - 09:42 AM
Post #1

D.I.C Regular
***

Joined: 21 Dec, 2008
Posts: 294


My Contributions
i have the following code form counting the remaining words from a textarea which i took from the internet, but it does not work although i have adapted it to my page.

i took it from this link : http://www.shiningstar.net/articles/articl...areacounter.asp.

Do you have any idea of what is wrong?

this is the java script:
CODE


<script type="text/javascript">

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
countfield.value = maxlimit - field.value.length;
}
</script>






this is the html:

CODE

<div id="apDiv37">File archive:</div>
   <form id="form3" name="form3" enctype="multipart/form-data" method="post" action="upload.php">
     <div id="apDiv36">
       <input name="file" type="file" id="file" size="62" />
      
      </div>
  <div id="apDiv38">File picture:</div>
  <div id="apDiv39">
  
      <input name="file_picture" type="file" id="file_picture" size="62" />
    
  </div>
  <div id="apDiv40">
  
      <input type="submit" name="submit_upload" id="submit_upload" value="Submit" />
    
  </div>
  <div id="apDiv41">
    <textarea name="descriere" id="descriere" cols="47" wrap="physical" rows="10"
    onKeyDown="textCounter(document.form3.descriere,document.form3.rem_char,300)"
    onKeyUp="textCounter(document.form3.descriere,document.form3.rem_char,300)"></textarea>
  
  </div>
  </form>
   <div id="apDiv46">
     <input readonly name="rem_char" type="text" id="rem_char" value="125" size="3" maxlength="3"  />
   </div>


BTW, on the internet it was language="javascript" not type="text/javascript". Is this an old script or what?

This post has been edited by livium: 27 Jun, 2009 - 11:07 AM

User is offlineProfile CardPM
+Quote Post


livium

RE: 'remaining Chars Count' Not Working (of Course)

27 Jun, 2009 - 11:20 AM
Post #2

D.I.C Regular
***

Joined: 21 Dec, 2008
Posts: 294


My Contributions
nevermind this topic.
i've found a script for this on your site

User is offlineProfile CardPM
+Quote Post

Valek

RE: 'remaining Chars Count' Not Working (of Course)

27 Jun, 2009 - 11:21 AM
Post #3

The Real SkyNet
Group Icon

Joined: 8 Nov, 2008
Posts: 625



Thanked: 43 times
Dream Kudos: 175
My Contributions
For future reference, this topic actually belongs in the JavaScript forum. Glad you found a solution all the same smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 08:12AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month