enable a textlable with javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Anna

    #1

    enable a textlable with javascript

    Hi, I have disabled a checkbox and a the lable for that (text in a
    <td>)

    <td class="label" width="90" id="recalc" disabled>Recalc ulate
    price</td>
    <td><input type="checkbox" name="cbRecalc" tabindex="3" size="15"
    maxlength="35" value="<%=sReca lc%>" disabled>

    When onChange on a drop down meny I whant to enable both of the above.
    I have tried the following javascript. The checkbox is enabled, but
    not the text in the table.

    function enableCheckbox( )
    {
    frmMain.cbRecal c.disabled = false;
    frmMain.recalc. disabled = false;
    }

    Can someone please give me a suggestion of something that works :-)
    /Anna
  • Evertjan.

    #2
    Re: enable a textlable with javascript

    Anna wrote on 18 jan 2005 in comp.lang.javas cript:
    [color=blue]
    > Hi, I have disabled a checkbox and a the lable for that (text in a
    > <td>)
    >
    > <td class="label" width="90" id="recalc" disabled>Recalc ulate
    > price</td>
    > <td><input type="checkbox" name="cbRecalc" tabindex="3" size="15"
    > maxlength="35" value="<%=sReca lc%>" disabled>
    >[/color]

    <td> does not "do" anything anyway,
    so disabling a <td> is a false concept.

    Perhaps you want to make a <tr> content invisible or non-displaying?

    The containing checkbox wil not be available to change then,
    and probably does not have to be disabled.

    Try this:

    =============== =============== =============== ========

    <table border=1>
    <tr><td>======= </td><td>=======</td></tr>

    <tr id="myTr1"><td> Recalculate price</td><td>
    <input type="checkbox" value="<%=sReca lc%>">
    </td></tr>

    <tr><td>======= </td><td>=======</td></tr>

    <tr id="myTr2"><td> Recalculate price</td><td>
    <input type="checkbox" value="<%=sReca lc%>">
    </td></tr>

    <tr><td>======= </td><td>=======</td></tr>
    </table>

    <button onclick="hide() ">Hide/show</button><br>
    <button onclick="noDisp lay()">Nodispal y/display</button><br>


    <script type="text/javascript">
    var myTr1 = document.getEle mentById("myTr1 ");
    var hide1=false;
    var myTr2 = document.getEle mentById("myTr2 ");
    var ndis1=false;

    function hide(){
    hide1 = !hide1
    myTr1.style.vis ibility=(hide1) ?"hidden":"visi ble"
    }

    function noDisplay(){
    ndis1 = !ndis1
    myTr2.style.dis play=(ndis1)?"n one":"block"
    }

    </script>

    =============== =============== =============== =========

    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)

    Comment

    Working...