Forums
This topic is locked
Add row function help
20 Aug 2007 23:44:51 Mike Mon posted:
Hi,Novice developer here seeking guidance. I have a form which inserts to 2 tables during submit which I've got working finally with DW workaround. Current roadblock I've encountered is how to enable multiple inserts into the 2nd table. Something like :
Table1
RecordID | Company
12345 | ABC
Table2
RecordID | Carrier | AccountNo
12345 | UPS | 565656
12345 | FedEx | 787878
I've incorporated a function to add rows to the carriers section of my form but not sure how to go about
1) make the first 2 cells dropdown menus, and the remaining as textfields
2) include newly created rows during submit
Here is the addrow function:
function addRow(id){
var tbody = document.getElementById
(id).getElementsByTagName("TBODY"

var row = document.createElement("TR"

var td1 = document.createElement("TD"

td1.appendChild(document.createTextNode(<%= Session("LastRec"


var td2 = document.createElement("TD"

td2.appendChild (document.createTextNode("column 2"

var td3 = document.createElement("TD"

td3.appendChild (document.createTextNode("column 3"

var td4 = document.createElement("TD"

td4.appendChild (document.createTextNode("column 4"

var td5 = document.createElement("TD"

td5.appendChild (document.createTextNode("column 5"

var td6 = document.createElement("TD"

td6.appendChild (document.createTextNode("column 6"

var td7 = document.createElement("TD"

td7.appendChild (document.createTextNode("column 7"

row.appendChild(td1);
row.appendChild(td2);
row.appendChild(td3);
row.appendChild(td4);
row.appendChild(td5);
row.appendChild(td6);
row.appendChild(td7);
tbody.appendChild(row);
}
And section on the form itself:
<br /><a href="javascript:addRow('myTable')">Add row</a>
<table width="808" border="0" align="center" cellpadding="3" cellspacing="0" class="color_one" id="myTable">
<tr>
<td class="style5"> </td>
<td class="style5">Carriers</td>
</tr>
<tr>
<td width="172"> </td>
<td width="172"><strong>Carrier</strong></td>
<td width="478"><strong>Carrier Status </strong></td>
<td width="478"><strong>Volume</strong></td>
<td width="478"><strong>Carrier Codes </strong></td>
<td width="478"><strong>Carrier Sales </strong></td>
<td width="478"><strong>E-Com Rep</strong></td>
</tr>
<tr>
<td><input name="textfield25" type="hidden" value="<%= Session("LastRec"

<td><select name="select" class="form">
<option value="null">--Please select--</option>
<%
While (NOT rsCarrierNames.EOF)
%><option value="<%=(rsCarrierNames.Fields.Item("CarrierName"


<%
rsCarrierNames.MoveNext()
Wend
If (rsCarrierNames.CursorType > 0) Then
rsCarrierNames.MoveFirst
Else
rsCarrierNames.Requery
End If
%>
</select></td>
<td><select name="select2" class="form">
<option value="null">--Please select--</option>
<%
While (NOT rsCarrierStatus.EOF)
%>
<option value="<%=(rsCarrierStatus.Fields.Item("CarrierStatus"


<%
rsCarrierStatus.MoveNext()
Wend
If (rsCarrierStatus.CursorType > 0) Then
rsCarrierStatus.MoveFirst
Else
rsCarrierStatus.Requery
End If
%>
</select></td>
<td><input name="textfield" type="text" class="form" /></td>
<td><input name="textfield2" type="text" class="form" /></td>
<td><input name="textfield3" type="text" class="form" /></td>
<td><input name="textfield4" type="text" class="form" /></td>
</tr>
<tr>
<tbody>
</tbody>
I hope I've included all pertinent information needed but let me know if I should include additional info.
Classic ASP and Access 2003
Thank you in advance.
Mike