By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,934 Members | 1,538 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,934 IT Pros & Developers. It's quick & easy.

Determine if a control exists in javascript

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.