Results 1 to 6 of 6

Thread: how do you check to see if a textbox exists? [Resolved]

  1. #1

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945

    how do you check to see if a textbox exists? [Resolved]

    I create some of my textboxes dynamically, and I want to know how to check if one of them is there or not.

    To explain better, I'll add that I use a loop to name them, always starting at 1, and there could be up to 16, but most of the time, there are only about 3-5.
    Last edited by ober0330; May 12th, 2004 at 01:17 PM.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  2. #2
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    let's say they're called txt0, txt1 etc.
    by called I mean id=txt1 not name=txt1
    Code:
    for (i=1; i<16; i++)
     {
     if (document.getElementById('txt'+i))
       {
       //It exists
       }
     }
    Have I helped you? Please Rate my posts.

  3. #3

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    Ok, this is what I have:
    Code:
         for (i=1; i<17; i++)
        {
            if (document.getElementById('act'+i))
            {
                URL = URL+"&act"+i+"="+document.dform.act+i+.value
            }
        }
    and it's giving me script errors. I think it has to do with how I'm doing the "document.dform.act+i+.value" part.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  4. #4
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    try changing
    document.dform.act+i+.value
    to:
    eval("document.dform.act"+i+".value")
    Have I helped you? Please Rate my posts.

  5. #5
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    or else to:
    document.getElementById("act"+i).value
    Have I helped you? Please Rate my posts.

  6. #6

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    I used the second one... that worked.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

Posting Permissions

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



Click Here to Expand Forum to Full Width