Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a textbox inside checkboxlist in C#?

Is is possible to add a textbox inside a checkbox list?

Here's the problem. I am having a checkbox list in which I need to insert and show a text box if certain checkbox is clicked. Say I have a list Item A Item B Item C Item D

now if user check Item B then a text box should appear between Item B and Item C. Any possibility doing this using C# or Jquery?

Gautam

like image 321
Gautam Avatar asked May 11 '12 14:05

Gautam


1 Answers

You can use JQuery to achieve that:

Here's the HTML code:

a<input type="checkbox" name="newsletter" value="Daily" />
b<input type="checkbox" name="newsletter" value="Weekly" />
c<input id="test" type="checkbox" name="newsletter" value="Monthly" />
<input id="txtbox" type="text">
d<input type="checkbox" name="newsletter" value="Yearly" />

Here's the JQuery:

$(document).ready(initialize);

    function initialize() {
       $("input#txtbox").hide(); 
       $(":checkbox").click(countChecked);    
    }


    function countChecked() {
        if ($("input#test").is(':checked')) {
            $("input#txtbox").show();                
        }
        else {
            $("input#txtbox").hide(); 
        }
    }

Here's a demo

Here's the source of information

like image 104
Luis Avatar answered Oct 06 '22 02:10

Luis