SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot nicc9's Avatar
    Join Date
    Jan 2005
    Location
    New Orleans, LA
    Posts
    181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face reset form fields inside container

    hi, all.

    I got stuck on a problem:

    I got a list of generated input fields (there is no way to know how many they are) inside a span withh an id.

    <span id="whatever">
    <input type="text ...
    <input type="text ...
    <input type="text ...
    </span>

    I also got a link that hides the content of the span.

    I need to reset the form fields when the link is clicked, but can't figure out how.

    can anybody help?

    thanks, I'd appreciate any suggestion.

    NICC9

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi nicc9, try this
    Code:
    function resetTextInputs(containerId)
    {
      var i, a, c = document.getElementById(containerId);
      if (c && c.getElementsByTagName)
      {
        a = c.getElementsByTagName('input');
        if (a)
        {
          for (i = 0; i < a.length; ++i)
          {
            if (a[i].type.toLowerCase() == 'text')
              a[i].value = '';
          }
        }
      }
    }

  3. #3
    SitePoint Zealot nicc9's Avatar
    Join Date
    Jan 2005
    Location
    New Orleans, LA
    Posts
    181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, I'll try it out and let you know!

  4. #4
    SitePoint Zealot nicc9's Avatar
    Join Date
    Jan 2005
    Location
    New Orleans, LA
    Posts
    181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    man, it works great, thanks a lot! I'll try to study your script and see if I can figure out how to do the same thing for a select.

    thanks again!


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
  •