Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with passing from data

Status
Not open for further replies.

bikebanditcom

Programmer
Jun 11, 2003
117
US
Ok,

So i have a form that has this button "Add a part" which adds a new line of form fields to the sheet, but it names each one for example partNumber is renamed to PartNumber_0, all the way thru 1, 2, 3, 4, so on.

below is the javascript i'm using to create the new rows dynamically.

<script language=&quot;JavaScript&quot;>
<!--
var recordCount = 0;
//start AddRow function block
function AddRow(){


var elemTbody, elemRow;
var elemCols = new Array(10);
var elempartNumber, elemQty, elemDealer, elemPrice, elemReason, elemExPartNumber, elemShipped, elemRcvd15Day, elemCrdtToBeIssd, elemCustRestockingFee, elemUnreturnableToSupp;

//create a reference to the tbody element in our table
elemTbody = document.getElementById(&quot;ResultTable&quot;).getElementsByTagName(&quot;tbody&quot;)[0];

//create the tr and td objects
elemRow = document.createElement(&quot;tr&quot;);
elemCols[0] = document.createElement(&quot;td&quot;);
elemCols[1] = document.createElement(&quot;td&quot;);
elemCols[2] = document.createElement(&quot;td&quot;);
elemCols[3] = document.createElement(&quot;td&quot;);
elemCols[4] = document.createElement(&quot;td&quot;);
elemCols[5] = document.createElement(&quot;td&quot;);
elemCols[6] = document.createElement(&quot;td&quot;);
elemCols[7] = document.createElement(&quot;td&quot;);
elemCols[8] = document.createElement(&quot;td&quot;);
elemCols[9] = document.createElement(&quot;td&quot;);
elemCols[10] = document.createElement(&quot;td&quot;);


//create our text inputs and our select dropdown
elemPartNumber = document.createElement(&quot;input&quot;);
elemQty = document.createElement(&quot;input&quot;);
elemDealer = document.createElement(&quot;select&quot;);
elemMercValue = document.createElement(&quot;input&quot;);
elemReason = document.createElement(&quot;select&quot;);
elemExPartNumber = document.createElement(&quot;input&quot;);
elemShipped = document.createElement(&quot;select&quot;);
elemRcvd15Day = document.createElement(&quot;select&quot;);
elemCrdtToBeIssd = document.createElement(&quot;select&quot;);
elemCustRestockingFee = document.createElement(&quot;select&quot;);
elemUnreturnableToSupp = document.createElement(&quot;select&quot;);

var elemOption;
var elemOption2;

//do the text boxes first
elemPartNumber.name = &quot;partNumber_&quot; + recordCount;
elemPartNumber.type = &quot;text&quot;;

elemQty.name = &quot;qty_&quot; + recordCount;
elemQty.type = &quot;text&quot;;
elemQty.size = &quot;4&quot;

elemMercValue.name = &quot;mercValue_&quot; + recordCount;
elemMercValue.type = &quot;text&quot;;
elemMercValue.size = &quot;8&quot;

elemExPartNumber.name = &quot;exPartNumber_&quot; + recordCount;
elemExPartNumber.type = &quot;text&quot;;

//do the select box next
elemDealer.name = &quot;dealer_&quot; + recordCount;
elemDealer.size = &quot;1&quot;;

elemReason.name = &quot;reason_&quot; + recordCount;
elemReason.size = &quot;1&quot;;

elemShipped.name = &quot;shipped_&quot; + recordCount;
elemShipped.size = &quot;1&quot;;

elemRcvd15Day.name = &quot;Rcvd15Day._&quot; + recordCount;
elemRcvd15Day.size = &quot;1&quot;;

elemCrdtToBeIssd.name = &quot;CrdtToBeIssd_&quot; + recordCount;
elemCrdtToBeIssd.size = &quot;1&quot;;

elemCustRestockingFee.name = &quot;CustRestockingFee_&quot; + recordCount;
elemCustRestockingFee.size = &quot;1&quot;;

elemUnreturnableToSupp.name = &quot;UnreturnableToSupp_&quot; + recordCount;
elemUnreturnableToSupp.size = &quot;1&quot;;

//add the options
var optCtr;
// creating a new option: text, value


//add the option
elemOption = new Option(&quot;Select One&quot;,&quot;Select One&quot;);
elemDealer.add(elemOption);
elemOption = new Option(&quot;HOUSE&quot;,&quot;HOUSE&quot;);
elemDealer.add(elemOption);
elemOption = new Option(&quot;PARTS&quot;,&quot;PARTS&quot;);
elemDealer.add(elemOption);
elemOption = new Option(&quot;TR&quot;,&quot;TR&quot;);
elemDealer.add(elemOption);
elemOption = new Option(&quot;VLE&quot;,&quot;VLE&quot;);
elemDealer.add(elemOption);
elemOption = new Option(&quot;SOUTH&quot;,&quot;SOUTH&quot;);
elemDealer.add(elemOption);


elemOption2 = new Option(&quot;Select One&quot;,&quot;Select One&quot;);
elemReason.add(elemOption2);
elemOption2 = new Option(&quot;Customer Return&quot;,&quot;Customer Return&quot;);
elemReason.add(elemOption2);
elemOption2 = new Option(&quot;Incorrect or Damaged&quot;,&quot;Incorrect or Damaged&quot;);
elemReason.add(elemOption2);
elemOption2 = new Option(&quot;Exchange&quot;,&quot;Exchange&quot;);
elemReason.add(elemOption2);
elemOption2 = new Option(&quot;BB - No Fee&quot;,&quot;BB - No Fee&quot;);
elemReason.add(elemOption2);
elemOption2 = new Option(&quot;BB - Pay Fee&quot;,&quot;BB - Pay Fee&quot;);
elemReason.add(elemOption2);

elemOption3 = new Option(&quot;Yes&quot;,&quot;Yes&quot;);
elemShipped.add(elemOption3);
elemOption3 = new Option(&quot;No&quot;,&quot;No&quot;);
elemShipped.add(elemOption3);

elemOption4 = new Option(&quot;Yes&quot;,&quot;Yes&quot;);
elemRcvd15Day.add(elemOption4);
elemOption4 = new Option(&quot;No&quot;,&quot;No&quot;);
elemRcvd15Day.add(elemOption4);


elemOption5 = new Option(&quot;Yes&quot;,&quot;Yes&quot;);
elemCrdtToBeIssd.add(elemOption5);
elemOption5 = new Option(&quot;No&quot;,&quot;No&quot;);
elemCrdtToBeIssd.add(elemOption5);


elemOption6 = new Option(&quot;Yes&quot;,&quot;Yes&quot;);
elemCustRestockingFee.add(elemOption6);
elemOption6 = new Option(&quot;No&quot;,&quot;No&quot;);
elemCustRestockingFee.add(elemOption6);


elemOption7 = new Option(&quot;No&quot;,&quot;No&quot;);
elemUnreturnableToSupp.add(elemOption7);
elemOption7 = new Option(&quot;Yes&quot;,&quot;Yes&quot;);
elemUnreturnableToSupp.add(elemOption7);


//add the inputs to the appropriate cells
elemCols[0].appendChild(elemPartNumber);
elemCols[1].appendChild(elemQty);
elemCols[2].appendChild(elemDealer);
elemCols[3].appendChild(elemMercValue);
elemCols[4].appendChild(elemReason);
elemCols[5].appendChild(elemShipped);
elemCols[6].appendChild(elemRcvd15Day);
elemCols[7].appendChild(elemCrdtToBeIssd);
elemCols[8].appendChild(elemCustRestockingFee);
elemCols[9].appendChild(elemUnreturnableToSupp);
elemCols[10].appendChild(elemExPartNumber);


//add the cols to the row
elemRow.appendChild(elemCols[0]);
elemRow.appendChild(elemCols[1]);
elemRow.appendChild(elemCols[2]);
elemRow.appendChild(elemCols[3]);
elemRow.appendChild(elemCols[4]);
elemRow.appendChild(elemCols[5]);
elemRow.appendChild(elemCols[6]);
elemRow.appendChild(elemCols[7]);
elemRow.appendChild(elemCols[8]);
elemRow.appendChild(elemCols[9]);
elemRow.appendChild(elemCols[10]);

//add the row to the tbody tag
elemTbody.appendChild(elemRow);

//increment recordCount and update hdnRecordCount input
recordCount++;
document.getElementById(&quot;recCount&quot;).value = recordCount;

}
// end of AddRow function block

//-->
</script>


any ideas how to get all those parts and corresponding info and insert it into a database? thankas dan
 
Why don't you use PartNumber text box as an array.
Each time to inster a new line of Form fields to sheet , Use the same name for the text Box.

After submiting the page When you will get a comma seperated list of the all partnumbers you have entered.

You will need to use Split() function to get the comma seperated list into an array and A unique incremental ID (or Array Index ) to associate and fetch the relevent row data.




Check and run the following code .I think this will help you.

<%@ Language=VBScript %>
<%
Response.Write (Request.Form(&quot;PartNumber&quot;) )
%>
<html>
<body>
<Form method=&quot;post&quot; >
<input type=&quot;text&quot; name=&quot;PartNumber&quot; size=&quot;1&quot;>
<p>

<input type=&quot;text&quot; name=&quot;PartNumber&quot; size=&quot;1&quot;>
</p>
<p>

<input type=&quot;text&quot; name=&quot;PartNumber&quot; size=&quot;1&quot;>
</p>
<input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;B1&quot;>
</form>
</body>

</html>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top