Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help on select all function please

    Hi expert,
    I'm not quite familiar with javascript, I am having problem with the select all function. In the drop down list have "Yes", and "No", I added select all function to get "Yes" but it didn't work. Did I mess up the getElementsByTagName there? thank you and have a good day.

    Code:
    <script>
    function selectall()
    {
    document.getElementsByTagName("table")[0].setAttribute("id","tableid");
    var tbl=document.getElementById('tableid');
    var tablelength = (document.getElementById('tableid').rows.length);
     
    for(var i = 1; i < tablelength ; i ++) 
     {
    	 document.getElementById('tableid').rows[i].cells[1].getElementsByTagName('input')[1].selected = true;
     }
    }
    PHP Code:
    <?php echo "<br>";
     echo 
    CHtml::button('Select All Yes',array('onclick'=>'selectall();''style' => 'width:100px; height:25px;cursor: pointer;'));
     
    ?>

    <?
    $memberFormConfig 
    = array(
          
    'elements'=>array(
            
    'moduleid'=>array(
                
    'type'=>'hidden',
                
    'maxlength'=>40,
            ),
            
    'modulename'=>array(
                
    'type'=>'text',
                
    'maxlength'=>40,
                
    'readonly'=>true,
            ),
            
    'canview'=>array(
                
    'type'=>'dropdownlist',
                
    'items'=>array(0=>'No',1=>'Yes',),
            
            ),
    ));

  • #2
    Regular Coder
    Join Date
    Mar 2008
    Location
    London
    Posts
    152
    Thanks
    4
    Thanked 42 Times in 42 Posts
    if you are selecting the checkboxes available in the first column of your table, then the correct property is checked rather then selected.

  • #3
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by niralsoni View Post
    if you are selecting the checkboxes available in the first column of your table, then the correct property is checked rather then selected.
    Hi and thanks for the reply, yea checkbox using checked. For drop down list, I just use selected or is there any I need to add on? Thank you.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •