473,394 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to get values in multiple checkbox?

Can you please help me how to get the multiple values of checkbox.


Expand|Select|Wrap|Line Numbers
  1. @Html.Label("Revision of Records:")<br />
  2. @Html.CheckBox("Change Address", new { @class = "appType", @id = "ChangeAddress", @onclick = "clkChangeAddress()", @name = "nRevRecords" })  Change Address<br />
  3. @Html.CheckBox("Change Civil Status", new { @class = "appType", @id = "ChangeCivilStatus", @onclick = "clkChangeCivilStatus()", @name = "nRevRecords" }) Change Civil Status<br />
  4. @Html.CheckBox("Change Name", new { @class = "appType", @id = "ChangeName", @onclick = "clkChangeName()", @name = "nRevRecords" }) Change Name<br />
  5. @Html.CheckBox("Change Date of Birth", new { @class = "appType", @id = "ChangeDateBirth", @onclick = "clkChangeDateBirth()", @name = "nRevRecords" })  Change Date of Birth<br />
  6. @Html.CheckBox("Others", new { id = "ChkBoxOthers", @class = "appType", @onclick = "clkOthers()" })  Others <br />
  7.  
Jul 9 '18 #1
2 3410
I think, you should going to Implement CheckBoxList in ASP.Net MVC.
visit this click here
Dec 1 '18 #2
Sherin
77 64KB
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" AutoEventWireup="true"%>    
  2.  
  3. <!DOCTYPE html>
  4.  
  5. <script runat="server">
  6.     protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
  7.     {
  8.         var items = from ListItem li in CheckBoxList1.Items
  9.                     where li.Selected == true
  10.                     select li;
  11.  
  12.         Label1.Text = "you checked item(s).....<br />";
  13.  
  14.         foreach(ListItem li in items)
  15.         {
  16.             Label1.Text += li.Text + " | " + li.Value + "<br />";
  17.         }
  18.     }
  19. </script>        
  20.  
  21. <html>        
  22. <head id="Head1" runat="server">        
  23.     <title>asp.net checkboxlist multiple selected values</title>
  24. </head>        
  25. <body>        
  26.     <form id="form1" runat="server">        
  27.     <div>        
  28.         <h2 style="color:MidnightBlue; font-style:italic;">        
  29.             asp.net example - checkboxlist multiple selected values
  30.         </h2>        
  31.         <hr width="550" align="left" color="Gainsboro" />        
  32.         <asp:Label       
  33.             ID="Label1"       
  34.             runat="server"      
  35.             Text="check item(s) from checkboxlist."
  36.             Font-Size="X-Large"
  37.             Width="350"
  38.             >      
  39.         </asp:Label>      
  40.         <br /><br />
  41.         <asp:CheckBoxList 
  42.             ID="CheckBoxList1"
  43.             runat="server"
  44.             RepeatColumns="2"
  45.             AutoPostBack="true"
  46.             OnSelectedIndexChanged="CheckBoxList1_SelectedIndexChanged"
  47.             >
  48.             <asp:ListItem Text="Rook" Value="1"></asp:ListItem>
  49.             <asp:ListItem Text="American Crow" Value="2"></asp:ListItem>
  50.             <asp:ListItem Text="White-necked Raven" Value="3"></asp:ListItem>
  51.             <asp:ListItem Text="Carrion Crow" Value="4"></asp:ListItem>
  52.             <asp:ListItem Text="Northern Raven" Value="5"></asp:ListItem>
  53.         </asp:CheckBoxList>  
  54.     </div>        
  55.     </form>        
  56. </body>        
  57. </html>
  58.  
Apr 22 '20 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Vanessa | last post by:
I have an ASP script which is used to upload files with Persits.Upload.1 object. But I can't get the values from mutliple checkboxes in the form like normally. <form method="post"...
6
by: rishabhshrivastava | last post by:
Hey All, Can someone suggest me a way to get the values of CheckBox(es) selected in a CheckBoxList control using JAVASCRIPT. I am pasting my current code gere but its not working need some...
4
by: ATDave | last post by:
So basically I'm just creating a form that I want the results e-mailed to somebody. I have everything working except for the checkmark sections that can have multiple answers. I'm a newbie when...
0
by: TechnoAtif | last post by:
<?php include "dbconnect.php"; include "commonFunc.php"; ?> <!----------------------------------> <table width="80%" border="1" cellpadding="2" cellspacing="0"> <tr > <td...
16
by: manius | last post by:
Hi. How do I insert in a db multiple checkbox results? I have 11 checkboxes, so how to do it in one query? Please :P
11
by: TechnoAtif | last post by:
INSERT AND UPDATE MULTIPLE CHECKBOX DATA USING PHPMYSQL OR JAVASCRIPT Hi All I want to check the multiple checkboxes update them after revisiting that page. I am taking the name as...
1
by: amel86 | last post by:
hello, i have a question. firstly sorry coz my grammar is not so good. i hope you all understand what question i will submit here.. the problem i face now is i cant retrieve all data that user...
0
by: Mary arilene | last post by:
Hi, I currenlt building a form and would like some help validating multiple checkboxes and receiving values. I'm using two two pages there asp pages. HTML code(with the body tag) ...
1
by: Raywin | last post by:
Hello everyone, i am facing a problem with multiple checkbox. I have set few checkbox as a selection, then send to database for search result. For example the checkbox including hotel features...
7
by: priya555 | last post by:
<?php include("database.php"); $query2="select prodcode,prodname,id from product"; $result2=mysqli_query($con,$query2); echo"<table border='2' align='center' cellpadding='0'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.