...

View Full Version : Need help on select all function please



KevMT
11-22-2012, 03:57 AM
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.



<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 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',),

),
));

niralsoni
11-22-2012, 02:43 PM
if you are selecting the checkboxes available in the first column of your table, then the correct property is checked rather then selected.

KevMT
11-23-2012, 01:23 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum