Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Script: Form field Limiter (Error found)

  1. #1
    Join Date
    Nov 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Script: Form field Limiter (Error found)

    In general the scripts works very fine, but if you are using variable names for input or textarea like "var[]" to use a arrays for your form input then the script produces an error.

    Because the use of arrays in form variables is a standard, the script should support this standard as well.

    <input type="text" name="var" /> ...works fine with scipt
    <input type="text" name="var[]" /> ...works not with script

    Who can help, because my JavaScript Skill is not good ...?

    with kind regards
    Stahlratte

  2. #2
    Join Date
    Nov 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs down Script: Form field Limiter

    Is there nobody with a clue here ...?

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

    Default

    Well, it is the weekend. Also, please allow at least 2 to 3 days for a response, as I usually try and answer questions twice a week.
    Last edited by ddadmin; 11-21-2004 at 10:26 AM.

  4. #4
    Join Date
    Nov 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up This sounds very good

    Ok ... that sounds very good.
    One completion: You can also use a full array name like "varname[value1]" for the imput's name and you will get the error as well.
    And if someone is asking what the sense is for an array like this in forms ... then think about 100 inputfields and how you will use the posted data in a loop or push them to a function.
    With arrays in a form you can save many code and accelerate your scripts.

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

    Default

    Warning: Please include a link to the DD script in question in your post. See this thread for the proper posting format for asking a question.

    Ok, I see the problem. I'm still thinking about it, but this is a tricky problem, since by default JavaScript- and this script- requires that each form element have a unique name in order to work. The array syntax (ie: var[]) carters to server side languages like PHP and CGI, but never JavaScript.

    I've made a note of the shortcoming of this script in this respect, though I can't say yet when to expect an update.

  6. #6
    Join Date
    Nov 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you for your investigations!
    How unfortunate, because "varname[value1]" would be a unique name and Javascript support Arrays as well.

    I'm not sure, but is it possible to use a unique ID instead the name of the element to proceed the functions ????
    So I could write <input id="xyz" name="myFormArray[xyz]" type="text" ....

    Best regards
    Stahlratte
    Last edited by Stahlratte; 11-24-2004 at 08:43 AM. Reason: additional comment

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

    Default

    Yes, rewriting the script to use the ID attribute would be one option. It would be more of a hassle integration wise, as the webmaster would need to add the ID attribute to the form elements in question while with the name attribute, it's normally already present.

    I'll give this some thought.

  8. #8
    Join Date
    Nov 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok, then I'll still waiting for your grandiosely solution :-)
    .. but the "ID Solution" would be really good enough for me.

    Best regards
    Stahlratte

  9. #9
    Join Date
    Nov 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Could someone give me a hint how the change the script to use IDs ??

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

    Default

    Good news. The script has just been updated for this, so it now supports both input by name or ID. Here it is: http://www.dynamicdrive.com/dynamici...limitinput.htm

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
  •