<head>
<style></style>
</head><body onload="onloadFun();">
<form name=frm>
<input type=button value="提交" onclick="checkAllNecessaryInputs();">
<table width="75" border="1">
<tr>
<td><input name="room_id" type=checkbox value="id0" onclick=clickBox(this) >  </td>
<td>
    <input name="id0_name" type=text value="name" disabled>
<input name="id0_age" type=text value="age" disabled>
</td>
</tr><tr>
<td><input name="room_id" type=checkbox value="id1" onclick=clickBox(this) > </td>
<td>
    <input name="id1_name" type=text  value="name" disabled>
<input name="id1_age" type=text value="age" disabled>  
</td>
</tr><tr>
<td><input name="room_id" type=checkbox value="id2" onclick=clickBox(this) >  </td>
<td>
    <input name="id2_name" type=text value="name" disabled>
<input name="id2_age" type=text value="age" disabled>  
</td>
</tr></table>
</form>
</body><SCRIPT LANGUAGE="JavaScript">
function clickBox(e)
{
  document.all(e.value+"_name").disabled=!e.checked ;
  document.all(e.value+"_age").disabled=!e.checked ;
 if(e.checked)
 {
  document.all(e.value+"_name").altStr=e.value+"_name" ;
  document.all(e.value+"_age").altStr=e.value+"_age" ;
 }
 else
 {
  document.all(e.value+"_name").altStr="" ;
  document.all(e.value+"_age").altStr="" ;
 }
}function onloadFun()
{
var a=document.getElementsByName("id");
for(var i=0;i<a.length;i++)
clickBox(a[i]);
}/**
* This function is to get if all necessary inputs have been inputted.
* Please give the NecessaryInput a property named "altStr".This property will be alert when it has not been inputed.
* For Example, 
*   This is a necessary input:<input altStr="Name">
*   This is not a necessary input:<input >
* JK 2003-12-08
*/
function checkAllNecessaryInputs(formObj)
{
if(formObj==null) formObj=document.forms[0];
var theFirstNecessaryInputToBeFilled=null;//Get it to focus;
var theAlertStr="";
var theNumOfInputsToBeFilled=0;

var theElementsOfTheForm=formObj.elements;
for (var i=0;i<theElementsOfTheForm.length;i++)
{
if(theNumOfInputsToBeFilled>9) break;
if((theElementsOfTheForm[i].altStr!=null)
&&(theElementsOfTheForm[i].altStr!="")
&&(theElementsOfTheForm[i].value=="")
)
{
theNumOfInputsToBeFilled++;
theAlertStr=theAlertStr+"\n"+theElementsOfTheForm[i].altStr;
if(theFirstNecessaryInputToBeFilled==null)
theFirstNecessaryInputToBeFilled=theElementsOfTheForm[i];
}
}
if(theNumOfInputsToBeFilled>0)
{
alert("Please input :"+ theAlertStr);
theFirstNecessaryInputToBeFilled.focus();
return false;
}
return true;
}
</SCRIPT>