473,395 Members | 1,689 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,395 software developers and data experts.

Javascript to C#

I have a bunch of dynamically created checkboxes that I add to the a
label in the html through my C# code. Then I also have a javascript
function that goes through and identifies which checkboxes are checked
when the user clicks on the submit button. My question now is, how
would I go about getting the list of checked boxes back to my C#
program? I am not sure if you can pass an array from javascript to C#
or even exactly how you create an array in javascript. However, my
code for finding the checked boxes is like this :

function Select(x){
l=document.form1;
n=l.elements.length;
var i=0;
for(i=0;i<n;i++){
if(l.elements[i].type=='checkbox' &&
l.elements[i].checked){
// Add element value to the array
}
}
}

any help would be greatly appreciated.

Thanks,
Dan

Oct 10 '06 #1
3 7350
Hello DFDavis,

Start from here http://groups.google.com/groups?q=do...vascript+array

as one solution is to create the string that represent your array (smth like
serialized array), put that string into hidden asp.net textbox and use form.submit()
to send data to server

DI have a bunch of dynamically created checkboxes that I add to the a
Dlabel in the html through my C# code. Then I also have a javascript
Dfunction that goes through and identifies which checkboxes are
Dchecked when the user clicks on the submit button. My question now
Dis, how would I go about getting the list of checked boxes back to my
DC# program? I am not sure if you can pass an array from javascript to
DC# or even exactly how you create an array in javascript. However,
Dmy code for finding the checked boxes is like this :
D>
Dfunction Select(x){
Dl=document.form1;
Dn=l.elements.length;
Dvar i=0;
Dfor(i=0;i<n;i++){
Dif(l.elements[i].type=='checkbox' &&
Dl.elements[i].checked){
D// Add element value to the array
D}
D}
D}
Dany help would be greatly appreciated.
D>
DThanks,
DDan
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Oct 10 '06 #2
If your checkboxes are inside a FORM field, then when the page is posted,
they will all be in the Request.Form collection.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"DFDavis" wrote:
I have a bunch of dynamically created checkboxes that I add to the a
label in the html through my C# code. Then I also have a javascript
function that goes through and identifies which checkboxes are checked
when the user clicks on the submit button. My question now is, how
would I go about getting the list of checked boxes back to my C#
program? I am not sure if you can pass an array from javascript to C#
or even exactly how you create an array in javascript. However, my
code for finding the checked boxes is like this :

function Select(x){
l=document.form1;
n=l.elements.length;
var i=0;
for(i=0;i<n;i++){
if(l.elements[i].type=='checkbox' &&
l.elements[i].checked){
// Add element value to the array
}
}
}

any help would be greatly appreciated.

Thanks,
Dan

Oct 10 '06 #3
Thank you both for your help, I finally got it working.

Dan
Peter wrote:
If your checkboxes are inside a FORM field, then when the page is posted,
they will all be in the Request.Form collection.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"DFDavis" wrote:
I have a bunch of dynamically created checkboxes that I add to the a
label in the html through my C# code. Then I also have a javascript
function that goes through and identifies which checkboxes are checked
when the user clicks on the submit button. My question now is, how
would I go about getting the list of checked boxes back to my C#
program? I am not sure if you can pass an array from javascript to C#
or even exactly how you create an array in javascript. However, my
code for finding the checked boxes is like this :

function Select(x){
l=document.form1;
n=l.elements.length;
var i=0;
for(i=0;i<n;i++){
if(l.elements[i].type=='checkbox' &&
l.elements[i].checked){
// Add element value to the array
}
}
}

any help would be greatly appreciated.

Thanks,
Dan
Oct 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.