Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Javascript
how can i count/access the no of Label/CheckBox/RadioButton web control into web page using java script????
 
Please help me anybody.....
Posted 4-Oct-12 23:09pm
Comments
_Amy at 5-Oct-12 5:41am
   
What have you tried yet? Any samples? Tried Google[^]?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try this
 
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
 
    $(document).ready(function () {
        var selectedCount = 0;
        var textcount = 0;
        var element;
 
        for (var i = 0; i < document.forms[0].elements.length; i++) {
            element = document.forms[0].elements[i];
            //alert(element.type);
            switch (element.type) {
                case 'text':
 
                        textcount=textcount+1;
 
                    break;
                case 'select-one':
 
                        selectedCount=selectedCount+1;
 
                    break;
                //etc - add cases for checkbox, radio, etc.
            }
        }
        alert("Textboxes:"+textcount + "," + "Dropdownlists:"+selectedCount);
    });
</script>
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 345
1 Gihan Liyanage 332
2 OriginalGriff 283
3 ClimerChinna 222
4 Zoltán Zörgő 170
0 Sergey Alexandrovich Kryukov 8,243
1 OriginalGriff 7,109
2 CPallini 2,598
3 Richard MacCutchan 1,980
4 Abhinav S 1,778


Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 5 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100