我用下面的JavaScript函数,为什么这个Javascript函数不起作用?
function get_check_value(formId,checkboxId,TxtboxId)
{
alert(formId);
var c_value = "";
for (var i=0; i < document.formId.checkboxId.length; i++)
{
if (document.formId.checkboxId[i].checked)
{
c_value = c_value + document.formId.checkboxId[i].value + "\n";
}
}
alert(c_value);
document.getElementById(TxtboxId).value= c_value;
// alert(c_value.value);
}
和我的PHP页面有这个,
<form name="orderform" id="orderform">
<input type="text" name="chId" id="chId" >
<table align="center" border="0">
<tr>
<td>Country</td>
</tr>
<? foreach($country as $row){ ?>
<tr>
<td><?= $row['dbCountry']; ?></td>
<td><input type="checkbox" name="CountrycheckId" id="CountrycheckId" value="<?= $row['dbCountryId']; ?> " onClick="get_check_value('orderform','CountrycheckId','chId')"></td>
<? } ?>
</tr>
</table>
</form>
我收到表格名称,checkboxid,文本ID警报中的JavaScript函数中。 ..但是 问题是用行 for (var i=0; i < document.formId.checkboxId.length; i++)
Webdeveloper工具栏显示这个错误
document.formId is undefined
@Itay还是同样的错误'的document.getElementById(formId) .checkboxId是未定义的# – udaya 2010-03-23 05:07:33