/    Sign up×
Community /Pin to ProfileBookmark

can we control the object is set to hidden or has been disable?

Hi,

Is that possible to control some object that is set to hidden or disable?

I got a check box and two dropdownlist(visible = false or enable = false, set to the property at the begining), if user checked the checkbox, the two dropdownlist will be show (visible = true or enable = true).

I get an object required error if I set the property(visible) of two object to false. If I set to (enable = false), it was do nothing.

Therefore, I try to set back the object to default(Visible = true, Enable = true), then the code is working.

Anyone have idea to help to solve this problem.
Thank you.

Calvin

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@HaganeNoKokoroSep 06.2004 — Can you show the code you are trying to use?
Copy linkTweet thisAlerts:
@steelersfan88Sep 06.2004 — For exmaple:<!-- DOCTYPE -->
<html>
<head>
<title>Example</title>
<script type="text/javascript">

Number.prototype.toStat = function() { return ((this==0) ? false : "disabled") }
function setStatus(nm,status) {
document.getElementById(nm).disabled = status.toStat();
}

</script>
</head>
<body>

<p>
<label>Enable<input type="radio" name="clr" checked onclick="setStatus('box',0)"></label><br>
<label>Disable<input type="radio" name="clr" onclick="setStatus('box',-1)"></label><br>
</p>
<div>
<select id="box">
<option value="fee">fee</option>
<option value="fie">fie</option>
<option value="foe">foe</option>
<option value="fum">fum</option>
</select>
</div>


</body>
</html>
will change that staus of the disabled property between false and disabled. Although, I'm not sure what you want, I can say:

> Make sure when setting the propert yto a Boolean value, set it to the Boolena (false), not the string implementation ("false").

Dr. Script
Copy linkTweet thisAlerts:
@KorSep 06.2004 — 
  • 1. There is no [b]enable[/b] HTML attribute, but there is a [b]disabled[/b] attribute which accept boolean true/false values.


  • 2. [b]visibility[/b] is a CSS attribute and has values [b]visible/hidden[/b] (for IE5+, NS6+, Moz...), not boolean true/false.


  • To manipulate disable status:
    [code=php]
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <script language="JavaScript" type="text/JavaScript">
    function dis(c,f,n){
    if(c.checked){
    f.elements[n].disabled=false;
    }
    else{f.elements[n].disabled=true;}
    }
    </script>
    </head>
    <body>
    <form>
    <input type="checkbox" onclick="dis(this,this.form,'list1')">
    <br>
    <select name="list1" disabled>
    <option>blah</option>
    <option>blah1</option>
    </select><br>
    <input type="checkbox" onclick="dis(this,this.form,'list2')">
    <br>
    <select name="list2" disabled>
    <option>foo</option>
    <option>foo2</option>
    </select>
    </form>
    </body>
    </html>
    [/code]


    To manipulate the elements CSS preset visibility:
    [code=php]
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <script language="JavaScript" type="text/JavaScript">
    function dis(c,f,n){
    if(c.checked){
    f.elements[n].style.visibility='visible';
    }
    else{f.elements[n].style.visibility='hidden';}
    }
    </script>
    </head>
    <body>
    <form>
    <input type="checkbox" onclick="dis(this,this.form,'list1')">
    <br>
    <select name="list1" style="visibility:hidden">
    <option>blah</option>
    <option>blah1</option>
    </select><br>
    <input type="checkbox" onclick="dis(this,this.form,'list2')">
    <br>
    <select name="list2" style="visibility:hidden">
    <option>foo</option>
    <option>foo2</option>
    </select>
    </form>
    </body>
    </html>
    [/code]
    Copy linkTweet thisAlerts:
    @edustreetauthorSep 07.2004 — Thank all of you.

    Calvin:p
    ×

    Success!

    Help @edustreet spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.28,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...