javascript选择指定checkbox,select,radio值代码
function selectcheckbox(name,value) {
var checkobject = document.getelementsbyname(name);
var valuevalues = value.split(",");
for(var j = 0; j < values.length; j++)
{
for (var i = 0; i < checkobject.length; i++)
{
if(checkobject[i].value == values[j])
{
checkobject[i].checked = true;
break;
}
}
}
}
function selectoption(name,value)
{
var options = document.getelementsbyname(name)[0].options;
for (var i = 0; i < options.length; i++)
{
if(options[i].value === value)
{
options[i].selected = true;
break;
}
}
}
function selectradio(name,value) {
var radioobject = document.getelementsbyname(name);
if(value === "")
{
radioobject[0].checked = true;
return;
}
for (var i = 0; i < radioobject.length; i++)
{
if(radioobject[i].value == value)
{
radioobject[i].checked = true;
break;
}
}
}