Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Oct 2004
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb If Checkbox is checked then show text box

    if there any way for this situation using javascript
    if the checkbox is checked then the table row, the "Guarantee No", ":" and input box will show.

    else hide it

    <table border="0" width="344">
    <tr>
    <td width="338" align="left" colspan="3" height="12"></td>
    </tr>
    <tr>
    <td width="122" align="left" height="22">Purpose Code</td>
    <td width="16" align="center" height="22">:</td>
    <td width="167" height="22">
    <input type = text name ="txtPurCode" tabindex= 25 size="20"></td>
    </tr>
    <tr>
    <td width="122" align="left" height="20">Guarantor</td>
    <td width="16" align="center" height="20">:</td>
    <td width="167" height="20">
    <input type="checkbox" name="chkGuar" value="ON" onclick = "c()"></td>
    </tr>

    <tr>
    <td width="122">Guarantee No</td>
    <td width="16">:</td>
    <td width="167">
    <input type = text name ='txtGRTNo' tabindex = 19 size="20"></td>
    </tr>
    <tr>
    <td width="338" align="left" colspan="3" height="12"></td>
    </tr>
    </table>

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Here's one possibility


    <HTML>
    <HEAD>
    <TITLE>Document Title</TITLE>

    <script>
    <!--
    function c(){}


    function test(){
    if(document["f1"]["chkGuar"].checked){
    document.getElementById("myrow").style.visibility="visible"
    }
    else{
    document.getElementById("myrow").style.visibility="hidden"
    }
    }
    //-->
    </script>
    </HEAD>
    <BODY>

    <FORM NAME="f1">
    <table border="1" width="344">
    <tr>
    <td width="338" align="left" colspan="3" height="12"></td>
    </tr>
    <tr>
    <td width="122" align="left" height="22">Purpose Code</td>
    <td width="16" align="center" height="22">:</td>
    <td width="167" height="22">
    <input type = text name ="txtPurCode" tabindex= 25 size="20"></td>
    </tr>
    <tr>
    <td width="122" align="left" height="20">Guarantor</td>
    <td width="16" align="center" height="20">:</td>
    <td width="167" height="20">
    <input type="checkbox" name="chkGuar" value="ON" onclick = "c() ; test()"></td>
    </tr>

    <tr id="myrow" style="visibility:hidden">
    <td width="122">Guarantee No</td>
    <td width="16">:</td>
    <td width="167">
    <input type = text name ='txtGRTNo' tabindex = 19 size="20"></td>
    </tr>
    <tr>
    <td width="338" align="left" colspan="3" height="12"></td>
    </tr>
    </table>
    </FORM>
    </BODY>
    </HTML>
    Last edited by Mr J; 10-29-2004 at 06:18 PM. Reason: Amended visibility mix up
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #3
    Regular Coder
    Join Date
    Oct 2004
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Errr... isn't that backwards? Checking the box hides the row.

    Fix by swapping "visible" and "hidden" in the javascript function, and changing style="visibility:visible" for style="visibility:hidden" in the table row.
    Last edited by Sayonara; 10-29-2004 at 12:31 PM.

  • #4
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    switch "hidden" and "visible"

  • #5
    Regular Coder
    Join Date
    Oct 2004
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by fci
    switch "hidden" and "visible"
    Also needs a change to the HTML - see my edit --^

  • #6
    Regular Coder
    Join Date
    Oct 2004
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In fact, it would be better to use display:none, otherwise the hidden row leaves a stonking great gap.

  • #7
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Sayonara
    In fact, it would be better to use display:none, otherwise the hidden row leaves a stonking great gap.
    I had to look up that word..
    To bombard with intense artillery fire src
    * tells everyone to put the weapons down *

  • #8
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    The key words here guys are;

    Here's one possibility
    The script is open to amendments as tanpl3 requires.

    The reason I did not use "display" was because it moves the contents when switching from "none" to "block" so I thought nah ......

    Still, I have to admit to getting the visibility thing arse upwards

    Silly me!
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #9
    Regular Coder
    Join Date
    Oct 2004
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I saw "Here's one possibility" but I chose to ignore it in the interests of promoting a good stonking.


    I tested with display: none/inline and it worked fine.

    Bizarrely, tested with display none/table-row and it went kablooie.

  • #10
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Stonkings good!


    Stonking = UK SLANG

    used to emphasize how good something is:

    "We had a stonking good time at the party last night"
    Last edited by Mr J; 10-29-2004 at 06:24 PM.
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #11
    New to the CF scene
    Join Date
    Dec 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question showing textbox in asp code

    hi folks,

    I'm new to this forum, but already very impressed. I've searching for code that does this for a while now, over the web. This is the only place I've found that can do.

    However, tho I can get it work stand-alone. I can't get it work in an page running asp code. I've cut & paste the code. Am I missing something???

    thanks

    ***************************************************
    In the HEAD:
    <script>
    <!--
    function c(){}

    function quantity(){
    if(document["f1"]["Upg_Select"].checked){
    document.getElementById("myQuan").style.visibility="visible"
    }
    else{
    document.getElementById("myQuan").style.visibility="hidden"
    }
    }
    //-->
    </script>


    In the BODY:
    <form method="POST" action="cart.asp" target="cart" onsubmit="return FrontPage_Form1_Validator(this)" name="f1">

    ...

    <tr>
    <td><font face="Verdana" size="2"><input type="checkbox" name="Upg_Select" value="<%=i%>" onclick = "c() ; quantity()"> <%=oRs("Upgrade")%>
    </td>
    <td id="myQuan" style="visibility:hidden"><font face="Verdana" size="2"><input type=text size=3 name="quantity">(Qty)</font></td>
    <td><font face="Verdana" size="2"> ... $<%=FormatNumber(oRs("Price"),2)%></td>
    </tr>
    ***************************************************


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •