Click here to Skip to main content
15,609,235 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a checkBoxList with "how did you hear about us" media, Flyer, School and Other.
I have an asp textbox where I want to store the values that are checked.
If the user checked media then media is added to the textbox.
If he than checked school then media and school is added to the textbox.
if he than checked other then the text will be visible with media and school in it and the user can add the other values that are not part of the checkboxlist.
If the user unchecked other then the values media and school will be in the textbox.

if that can be done without the page being postback?

<asp:CheckBoxList ID="ChBMedia" runat="server">
                        <asp:ListItem>Media Article (TV/Radio/Newspaper) </asp:ListItem>
                        <asp:ListItem>School (for student volunteers) </asp:ListItem>

What I have tried:

what i have tried is not worth sending up
Updated 2-Mar-16 17:25pm

Check out the following plugin:

[Chosen JS^]

Look under multiple select, it does what I think you want to do.
Share this answer
Let's use jQuery as you don't want to do postback. Try with below code

HTML code:
<asp:checkboxlist id="ChBMedia" runat="server" xmlns:asp="#unknown">
	<asp:listitem>Media Article (TV/Radio/Newspaper) </asp:listitem>
	<asp:listitem>School (for student volunteers) </asp:listitem>
<asp:textbox id="txtMedia" runat="server" xmlns:asp="#unknown"></asp:textbox>

Javascript code:
<script type="text/javascript" src=""></script>
<script type="text/javascript">
$('#ChBMedia').on('click', ':checkbox', function() {
    if ($(this).is(':checked')) {
        // handle checkbox check
		var value = $(this).text();

		// append value to text box
		if($("#txtMedia").val() == "")
			$("#txtMedia").val($("#txtMedia").val() + ", " + value);

Above javascript code will append value to textboxe with comma separated onclick of checkbox. If you have different requirement then you can change the logic in javascript.
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