469,271 Members | 1,370 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

Determine if a control exists in javascript

G'day All,

I'm creating a classic ASP page that draws pieces dynamically.

In some cases, I need to draw a <selecttag and populate it.

I then want to hide this control immediately and pop it back up if the
users chooses the corresponding checkbox.

I have the pop up part nailed, but hiding it when the page loads is
eluding me....

This javascript code works well to hide it, if it exists :
frmMain.cboJumpOffPoint.style.display='none';

The problem is, if I haven't drawn the <selecttag, the code fails...

Is there a way to determine if a control exists in javascript before I
attempt to hide it?

Thanks in advance,

Doug.

Oct 7 '07 #1
3 3877
On Oct 8, 1:03 am, Melbfella <d...@dodeonline.comwrote:
G'day All,

I'm creating a classic ASP page that draws pieces dynamically.

In some cases, I need to draw a <selecttag and populate it.

I then want to hide this control immediately and pop it back up if the
users chooses the corresponding checkbox.

I have the pop up part nailed, but hiding it when the page loads is
eluding me....

This javascript code works well to hide it, if it exists :
frmMain.cboJumpOffPoint.style.display='none';

The problem is, if I haven't drawn the <selecttag, the code fails...
Give it a class, then modify the class rule in the style sheet to
toggle the element's visibility display attribute. That way it
doesn't matter whether the control exists or not when you do it.

You will need to address usability issues for those with javascript
disabled.

--
Rob

Oct 7 '07 #2
On Oct 7, 10:15 pm, RobG <rg...@iinet.net.auwrote:
Give it a class, then modify the class rule in the style sheet to
toggle the element's visibility display attribute. That way it
doesn't matter whether the control exists or not when you do it.
Is there a well supported method to do this yet? Last time I looked
into it, I seem to recall that one browser supported the standard
method, one supported a proprietary method, and the others didn't
support any method.

--
David Dorward
http://dorward.me.uk/
http://blog.dorward.me.uk/

Oct 8 '07 #3
David Dorward wrote:
On Oct 7, 10:15 pm, RobG <rg...@iinet.net.auwrote:
>Give it a class, then modify the class rule in the style sheet to
toggle the element's visibility display attribute. That way it
doesn't matter whether the control exists or not when you do it.

Is there a well supported method to do this yet? Last time I looked
into it, I seem to recall that one browser supported the standard
method, one supported a proprietary method, and the others didn't
support any method.
Provided s/browser/DOM/g, that has not changed.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Oct 8 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

18 posts views Thread by Christopher W. Douglas | last post: by
3 posts views Thread by Web Webon | last post: by
88 posts views Thread by Mike | last post: by
9 posts views Thread by Adam | last post: by
3 posts views Thread by Jordan | last post: by
1 post views Thread by rn5a | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.