Forums

ASP

This topic is locked

Add row function help

Posted 20 Aug 2007 23:44:51
1
has voted
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"[0];
var row = document.createElement("TR"
var td1 = document.createElement("TD"
td1.appendChild(document.createTextNode(&lt;%= Session("LastRec" %&gt<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
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:
&lt;br /&gt;&lt;a href="javascript:addRow('myTable')"&gt;Add row&lt;/a&gt;
&lt;table width="808" border="0" align="center" cellpadding="3" cellspacing="0" class="color_one" id="myTable"&gt;
&lt;tr&gt;
&lt;td class="style5"&gt;&nbsp;&lt;/td&gt;
&lt;td class="style5"&gt;Carriers&lt;/td&gt;

&lt;/tr&gt;

&lt;tr&gt;
&lt;td width="172"&gt;&nbsp;&lt;/td&gt;
&lt;td width="172"&gt;&lt;strong&gt;Carrier&lt;/strong&gt;&lt;/td&gt;
&lt;td width="478"&gt;&lt;strong&gt;Carrier Status &lt;/strong&gt;&lt;/td&gt;
&lt;td width="478"&gt;&lt;strong&gt;Volume&lt;/strong&gt;&lt;/td&gt;
&lt;td width="478"&gt;&lt;strong&gt;Carrier Codes &lt;/strong&gt;&lt;/td&gt;
&lt;td width="478"&gt;&lt;strong&gt;Carrier Sales &lt;/strong&gt;&lt;/td&gt;
&lt;td width="478"&gt;&lt;strong&gt;E-Com Rep&lt;/strong&gt;&lt;/td&gt;

&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;&lt;input name="textfield25" type="hidden" value="&lt;%= Session("LastRec" %&gt;" /&gt;&lt;/td&gt;

&lt;td&gt;&lt;select name="select" class="form"&gt;
&lt;option value="null"&gt;--Please select--&lt;/option&gt;
&lt;%
While (NOT rsCarrierNames.EOF)
%&gt;&lt;option value="&lt;%=(rsCarrierNames.Fields.Item("CarrierName".Value)%&gt;"&gt;&lt;%=(rsCarrierNames.Fields.Item("CarrierName".Value)%&gt;&lt;/option&gt;
&lt;%
rsCarrierNames.MoveNext()
Wend
If (rsCarrierNames.CursorType &gt; 0) Then
rsCarrierNames.MoveFirst
Else
rsCarrierNames.Requery
End If
%&gt;
&lt;/select&gt;&lt;/td&gt;
&lt;td&gt;&lt;select name="select2" class="form"&gt;
&lt;option value="null"&gt;--Please select--&lt;/option&gt;
&lt;%
While (NOT rsCarrierStatus.EOF)
%&gt;
&lt;option value="&lt;%=(rsCarrierStatus.Fields.Item("CarrierStatus".Value)%&gt;"&gt;&lt;%=(rsCarrierStatus.Fields.Item("CarrierStatus".Value)%&gt;&lt;/option&gt;
&lt;%
rsCarrierStatus.MoveNext()
Wend
If (rsCarrierStatus.CursorType &gt; 0) Then
rsCarrierStatus.MoveFirst
Else
rsCarrierStatus.Requery
End If
%&gt;
&lt;/select&gt;&lt;/td&gt;
&lt;td&gt;&lt;input name="textfield" type="text" class="form" /&gt;&lt;/td&gt;
&lt;td&gt;&lt;input name="textfield2" type="text" class="form" /&gt;&lt;/td&gt;
&lt;td&gt;&lt;input name="textfield3" type="text" class="form" /&gt;&lt;/td&gt;
&lt;td&gt;&lt;input name="textfield4" type="text" class="form" /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;tbody&gt;
&lt;/tbody&gt;

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

Reply to this topic