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