当checkbox1被选中后,表格的第二行才出现,不选中则不显示,并且在选中的状态下,表单提交判断url文本域不能为空。
1<form action="" method="POST">
2<table border="1" cellpadding="0" cellspacing="0" width="100%">
3<tr>
4<td colspan="2" width="100%"><input name="checkbox1" type="checkbox" value="ON"/></td>
5</tr>
6<tr>
7<td width="50%">url</td>
8<td width="50%"><input name="url" size="20" type="text"/></td>
9</tr>
10</table>
11</form>
---------------------------------------------------------------
1<script>
2function showRow(){
3tRow = document.getElementById('abc');
4if(!tRow) return;
5if(tRow.style.display=='none') tRow.style.display="";
6}
7function hideRow(){
8tRow = document.getElementById('abc');
9if(!tRow) return;
10if(tRow.style.display!='none') tRow.style.display="none";
11}
12</script>
1<form action="" method="POST">
2<table border="1" cellpadding="0" cellspacing="0" width="100%">
3<tr>
4<td colspan="2" width="100%"><input checked="" name="checkbox1" onclick="if(this.checked){showRow();}else{hideRow();}" type="checkbox" value="ON"/></td>
5</tr>
6<tr id="abc" style="display:none">
7<td width="50%">url</td>
8<td width="50%"><input name="url" size="20" type="text"/></td>
9</tr>
10</table>
11<input name="submit" onclick="if(this.form.checkbox1.checked && this.form.url.value==''){alert('must fill URL...')}" type="submit" value="submit"/>
12</form>