Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my first day of html coding andI have html page and on this page there is a check box,I want that when the user check this box,textarea should be open in the same page.
Posted
Updated 10-Jan-21 0:21am

Using JQuery

$("selector for checkbox".change(function()
{
  if($(this).is(':checked') )
    $("selector for textarea").show();
  else
     $("selector for textarea").hide();
});
 
Share this answer
 
Comments
Uday P.Singh 11-Apr-12 8:39am    
5!
vikky08 11-Apr-12 8:46am    
But I do't know how to use it,can you please describe it!
[no name] 11-Apr-12 10:21am    
Add this in the window.load event or using JQuery...

$(document).ready(function()
...add code here...
});

Add this to a script element at the top of your page
Try this with native javascript:

JavaScript
function ShowHide(chk,txt)

    {

        if(document.getElementById(chk).checked)

            document.getElementById(txt).style.display='';

        else

            document.getElementById(txt).style.display='none';

    }


hope it helps :)
 
Share this answer
 
Comments
[no name] 11-Apr-12 10:24am    
Using JQuery is much better. It is cross browser and completes some functionality for you. For this you still need to add the handler to the checkbox element. The JQuery code above does it automatically.

Old school manual JavaScript is dead. It's like using Notepad to write code. Sure it can be done, but an IDE and framework are much more productive
Uday P.Singh 11-Apr-12 11:47am    
I agree with you, thats why voted your answer. I just gave the another way, If the OP doesn't want to use Jquery.
Dfgd<<pre lang="text"></pre>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900