InsertRow und InsertCell

Fanatico

Mitglied
Hallo!

Ich habe mich mal mit den beiden Funktionen beschäftigt, aber ich blicke da nicht so recht durch.

Habe mal mein Code-Beispiel beigefügt.

HTML:
<html>
<head>
<title>TEST</title>
<script type="text/javascript">
<!--
 function addContactType()
{

}
//-->
</script>

</head>
<body>
<table cellspacing="0">
<colgroup>
<col width="15%">
<col width="65%">
<col width="*">
</colgroup>
<tbody>
<tr>
<td><select size="1" name="selectType"><option>&nbsp;</option><option selected>Phone</option><option>Fax</option><option>email</option><option>Address</option><option>ZIP Code</option><option>City</option><option>Country</option></select></td><td><input maxlength="50" size="60" value="+39 478374589378957" name="contactValue" class="text" type="text"></td><td>&nbsp;</td>
</tr>
<tr>
<td><select size="1" name="selectType"><option>&nbsp;</option><option>Phone</option><option selected>Fax</option><option>email</option><option>Address</option><option>ZIP Code</option><option>City</option><option>Country</option></select></td><td><input maxlength="50" size="60" value="+39 45738957" name="contactValue" class="text" type="text"></td><td>&nbsp;</td>
</tr>
<tr>
<td><select size="1" name="selectType"><option>&nbsp;</option><option>Phone</option><option>Fax</option><option selected>email</option><option>Address</option><option>ZIP Code</option><option>City</option><option>Country</option></select></td><td><input maxlength="50" size="60" value="LG@fshjkfhsj" name="contactValue" class="text" type="text"></td><td>&nbsp;</td>
</tr>
<tr>
<td><select size="1" name="selectType"><option>&nbsp;</option><option>Phone</option><option>Fax</option><option>email</option><option selected>Address</option><option>ZIP Code</option><option>City</option><option>Country</option></select></td><td><input maxlength="50" size="60" value="SHFJKHFHKHSDFHKJDHFKDHF" name="contactValue" class="text" type="text"></td><td>&nbsp;</td>
</tr>
<tr>
<td><select size="1" name="selectType"><option>&nbsp;</option><option>Phone</option><option>Fax</option><option>email</option><option>Address</option><option>ZIP Code</option><option selected>City</option><option>Country</option></select></td><td><input maxlength="50" size="60" value="Rome" name="contactValue" class="text" type="text"></td><td>&nbsp;</td>
</tr>
<tr>
<td><select size="1" name="selectType"><option>&nbsp;</option><option>Phone</option><option>Fax</option><option>email</option><option>Address</option><option>ZIP Code</option><option>City</option><option selected>Country</option></select></td><td><input maxlength="50" size="60" value="Italy" name="contactValue" class="text" type="text"></td><td>&nbsp;</td>
</tr>
</tbody>
</table>
<input value="New Contact Type" type="button" onclick="addContactType()">
</body>
</html>

Wenn man auf den Button drückt, soll einfach eine weitere Zeile mit einer Select- und Textbox erscheinen.

Wäre nett, wenn mir da jemand weiterhelfen könnte.
 
Alternativ könntest du einfach einen Knoten mit cloneNode() klonen und ihn dann so verändern, dass er passt. Du könntest auch vorher diese Zeiele anlegen und nur die visibilty ändern.

Ansonsten ist es etwas code-aufwänding das ganze über insertRow()/Cell() zu machen.
 
Hallo!

Da es möglich sein soll, n Zeilen einzufügen, wäre dies mit der visibility etwas schlecht.

Wie genau sähe das denn mit dem Knoten für mein Problem aus?
 
Zurück