我有一个 html 表。它包含一个作为一行的下拉框。我需要根据下拉框中的值将值附加到表中。我不知道该怎么做。所以我使用了两张桌子。我的html代码如下:
<html>
<head>
<script src="js/jquery.js" type="text/javascript"></script>
<script language="javascript">
function change() {
document.getElementById('addPfForm1').style.display = 'block';
if (document.getElementById('addPfForm').type.value == "hBased") {
$('#addPfForm1').html("");
$('#addPfForm1').html("<font size='2'><table bgcolor='#D2DFEF'><col width='170'><col width='30'><td>Market Value:</td><td><input type='text' name='mktVal'/></td></tr><tr><td>wtScheme:</td><td><input type='text' name='wtScheme'/></td></tr><tr><td></td><td><input type='button' value='OK' onclick='addPortfolioFunction()'/><input type='button' value='CANCEL' onclick='addPortfolioFunction(this.value )'/></td></tr></table></font>");
}
if (document.getElementById('addPfForm').type.value == "setBased") {
$('#addPfForm1').html("");
$('#addPfForm1').html("<font size='2'><table bgcolor='#D2DFEF'><col width='170'><col width='30'><tr><td>rules</td><td><input type='text' name='shrsSplitAdjusted'/></td></tr><tr><td></td><td><input type='button' value='OK' onclick=alert('hai');/><input type='button' value='CANCEL' onclick='addPortfolioFunction(this.value )'/></td></tr></table></font>");
}
}
</script>
</head>
<body>
<form id='addPfForm'>
<font size='2'>
<table bgcolor='#D2DFEF'>
<col width='170'>
<col width='30'>
<tr>
<td>
Portfolio Name:
</td>
<td>
<input type='text' name='name'>
</td>
</tr>
<tr>
<td>
Group Name:
</td>
<td>
<input type='text' name='group'>
</td>
</tr>
<tr>
<td>
Type:
</td>
<td>
<select id='type' onchange='change();'>
<option value='hBased'>H Based</option>
<option value='setBased'>Set Based</option>
</select>
</td>
</tr>
<tr>
</table>
</font>
</form>
<form id='addPfForm1'>
<br>
</form>
</body>
</html>
如何根据下拉选择而不是这种糟糕的方法将值附加到表中?