SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    form extending script error

    I have this page with a JS script to extend extra fields in a form if needed.

    http://darice.org/example/form.html

    Every time the script creates an extra field it's supposed to number the names. like:

    <input name="item1" type="text" />
    <input name="item2" type="text" />

    This way each field has a unique name for when passing the form to the server.

    In my case the scripts works fine but it doesn't add the numbers behind the field names. If anyone could check out the script see if you spot any errors I missed.

    Secondly if I put the JS script in an external .js file and include it it doesn't work anymore. Which is very strange.

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Change
    Code:
    var newField = newFields.childNodes;
    to
    Code:
    var newField = newFields.getElementsByTagName("input");
    And about the script not working in an external file, please show an url showing this issue please

    p.s Welcome to the forum!

  3. #3
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the pointer! works now...

    About the .js include check out this page:

    http://darice.org/example/form_2.html

  4. #4
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It doesn't work because you included the script tag insde the JavaScript file, remove it, and the comment and it will work fine.

  5. #5
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Allright! Thanks for the help!


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
  •