problem with condition in checkboxes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jesmi
    New Member
    • Apr 2007
    • 53

    problem with condition in checkboxes

    hi all

    my requirement is that when i clik my chek box the corresponding textbox should be enabled otherwise it should be disabled. following is my code:

    <tr bgcolor="<%=row Color%>">
    <td>&nbsp;</td>
    <td><input type="checkbox" name="chkbox2" value="Y"></td>
    <td>Party code </td>
    <td><input name="partyCd" type="text" maxlength="20" onDblClick="cal lLov('../lov/lovPartyCd.jsp' ,'300','316')" size="10" id="partyCd" readonly>
    <input name="partyDesc " type="text" onDblClick="cal lLov('../lov/lovPartyCd.jsp' ,'300','316')" size="40" maxlength="10" readonly></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>

    please make change in this code to fulfill my requirements.

    thanks in advance
  • jesmi
    New Member
    • Apr 2007
    • 53

    #2
    chekbox disabling condition

    hi all

    my requirement is that when i clik my chek box the corresponding textbox should be enabled otherwise it should be disabled. following is my code:

    <tr bgcolor="<%=row Color%>">
    <td>&nbsp;</td>
    <td><input type="checkbox" name="chkbox2" value="Y"></td>
    <td>Party code </td>
    <td><input name="partyCd" type="text" maxlength="20" onDblClick="cal lLov('../lov/lovPartyCd.jsp' ,'300','316')" size="10" id="partyCd" readonly>
    <input name="partyDesc " type="text" onDblClick="cal lLov('../lov/lovPartyCd.jsp' ,'300','316')" size="40" maxlength="10" readonly></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>

    please make change in this code to fulfill my requirements.

    thanks in advance
    Last edited by gits; Jul 22 '07, 01:20 PM. Reason: threads merged

    Comment

    • prometheuzz
      Recognized Expert New Member
      • Apr 2007
      • 197

      #3
      Hi jesmi, I moved your thread from Java to JavaScript. Although the two names look a like, they're not the same language. I'm sure you'll get some assistence here.

      Good luck.

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        Originally posted by jesmi
        hi all

        my requirement is that when i clik my chek box the corresponding textbox should be enabled otherwise it should be disabled. following is my code:

        <tr bgcolor="<%=row Color%>">
        <td>&nbsp;</td>
        <td><input type="checkbox" name="chkbox2" value="Y"></td>
        <td>Party code </td>
        <td><input name="partyCd" type="text" maxlength="20" onDblClick="cal lLov('../lov/lovPartyCd.jsp' ,'300','316')" size="10" id="partyCd" readonly>
        <input name="partyDesc " type="text" onDblClick="cal lLov('../lov/lovPartyCd.jsp' ,'300','316')" size="40" maxlength="10" readonly></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        </tr>

        please make change in this code to fulfill my requirements.

        thanks in advance
        hi ...

        simply create a javascript-function that you call 'onclick' of your checkbox like the following example:

        [HTML]<input type="checkbox" name="chkbox2" onclick="set_te xtbox_state(thi s);" value="Y">
        [/HTML]

        the function gets the checkbox-obj itself passed to it and so we may ask it for the checked-property:

        [CODE=javascript]function set_textbox_sta te(command_obj) {
        // get a reference to the textbox-node
        var tb = document.getEle mentById('party Cd');

        if (command_obj.ch ecked) {
        tb.removeAttrib ute('readonly') ;
        } else {
        tb.setAttribute ('readonly', 'true');
        }
        }[/CODE]

        kind regards

        Comment

        Working...