|
-
May 12th, 2004, 12:17 PM
#1
Thread Starter
Frenzied Member
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.
-
May 12th, 2004, 12:24 PM
#2
Frenzied Member
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. 
-
May 12th, 2004, 01:05 PM
#3
Thread Starter
Frenzied Member
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.
-
May 12th, 2004, 01:07 PM
#4
Frenzied Member
try changing
document.dform.act+i+.value
to:
eval("document.dform.act"+i+".value")
Have I helped you? Please Rate my posts. 
-
May 12th, 2004, 01:10 PM
#5
Frenzied Member
or else to:
document.getElementById("act"+i).value
Have I helped you? Please Rate my posts. 
-
May 12th, 2004, 01:17 PM
#6
Thread Starter
Frenzied Member
I used the second one... that worked.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|