Results 1 to 5 of 5

Thread: Form field Limiter Help?

  1. #1
    Join Date
    Feb 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Form field Limiter Help?

    1) Script Title: Form field Limiter

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...limitinput.htm

    3) Describe problem:
    Hello all,
    I have two text areas on my form and I want this script to check both fields. But I can only get it to check one of them.

    This is my form before I add the script:-
    HTML Code:
    <h3>What are your main issues?</h3><br>
      <form name="all_issues" action="save_issues.php" method="post">
      <textarea rows="6" cols="60" name="main_issues"></textarea><br>
     <br><hr><br>
      <h3>Please enter any further suggestions</h3><br>
      <textarea rows="6" cols="60" name="suggest">
    </textarea>
      <br></center><br>
      <input type="submit" value="Save / Update"></form><hr>
    I then put the main part of script in the head and edited the part above like so:-
    HTML Code:
    <h3>What are your main issues?</h3><br>
      <form name="all_issues" action="save_issues.php" method="post">
      <textarea rows="6" cols="60" id="issues" name="main_issues"> </textarea><br>
    <script>
    displaylimit("","issues",2000)
    </script>
     <br><hr><br>
      <h3>Please enter any further suggestions</h3><br>
      <textarea rows="6" cols="60" id="suggestion" name="suggest"></textarea>
      <br>
    <script>
    displaylimit("","suggestion",2000)
    </script>
    </center><br>
      <input type="submit" value="Save / Update"></form><hr>
    The top text area display limit works fine, but the second remains static.

    What am I doing wrong? I thought using id's would allow the use of two text areas?

    Many Thanks

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Try switching to entering the form field's name instead of its ID. So in your case:

    Code:
    <h3>What are your main issues?</h3><br>
      <form name="all_issues" action="save_issues.php" method="post">
      <textarea rows="6" cols="60" id="issues" name="main_issues"> </textarea><br>
    <script>
    displaylimit("document.all_issues.main_issues","",2000)
    </script>
     <br><hr><br>
      <h3>Please enter any further suggestions</h3><br>
      <textarea rows="6" cols="60" id="suggestion" name="suggest"></textarea>
      <br>
    <script>
    displaylimit("document.all_issues.suggest","",2000)
    </script>
    </center><br>
      <input type="submit" value="Save / Update"></form><hr>
    This script is rather old and not exactly intuitive. Another script up for a makeover soon.

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Quote Originally Posted by ddadmin
    displaylimit("document.all_issues.suggest","",2000)
    Don't access forms or elements like that: it's non-standard and can cause confusion if the form or element has a name identical to a property of the document or form objects. Instead, use:
    Code:
    displaylimit("document.forms['all_issues'].elements['suggest']","",2000))
    You're not wrong about this script needing a makeover... here's a candidate. It was written on the spur of the moment, so documentation is still sparse.
    Last edited by Twey; 02-14-2007 at 07:11 PM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Trey:
    I don't doubt for a moment your version is better than the current one. When I get to updating this script I'll take a look again at your code, and possibly (with your permission of course) just go with it. I enjoy rewriting old scripts on DD though- it has this cleansing effect hehe.

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Trey:
    Again?
    When I get to updating this script I'll take a look again at your code, and possibly (with your permission of course) just go with it.
    Of course.
    I enjoy rewriting old scripts on DD though- it has this cleansing effect hehe.
    Heh -- there are plenty to go around
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •