Accessing controls in template column with JavaScript

P

Peter Cresswell

Hi Guys & Gals,

Is it possible to access controls (e.g. a CheckBox) within a template column
in a datagrid with JavaScript?

I would like to count the number of rows in my datagrid with checked boxes
on the client side, i.e. without a post back.

Anybody know how to do this?
I would also like to do a hotmail style select all on the client side. Is
this possible with a datagrid?

Thanks in advance!

Peter
 
C

Cristian Suazo

Could this be something?

<html>
<body>

<script language='Javascript'>
<!--
function CountCheck(){
var counter = 0;
var counter_checked = 0;
for(i=0; i < document.forms(0).length; i++){
if (document.forms(0).elements(i).type.indexOf("checkbox") > -1){
if (document.forms(0).elements(i).checked == true) counter_checked++;
counter++;
}
}
alert("You have " + counter + " checkboxes, " + counter_checked + " are
checked...")
}
//-->
</script>

<form>
<input type="checkboX"><br>
<input type="checkbox"><br>
<input type="checkbox"><br>
<input type=button onClick="CountCheck();" value="Count checkboxes"/>
</form>

</body>
</html>

Cheers
Cristian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top