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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loop thru dynamic form elements

Status
Not open for further replies.

bikebanditcom

Programmer
Jun 11, 2003
117
US
I have the following javascript, that as you can see dynamically generates two fields, i'll be adding two more fields that will be dependendent on the first two fields, i haven't worked out the dependendent drop downs, but i need to know how i can loop thru this code in vbscript on my take_sale.asp page, can anyone help? Thank you


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


var elemTbody, elemRow;
var elemCols = new Array(2);
var elemPackType, elemPackLevel

//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;);



//create our text inputs and our select dropdown
elemPackType = document.createElement(&quot;select&quot;);
elemPackLevel = document.createElement(&quot;select&quot;);

var elemOption;
var elemOption2;

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

elemPackLevel.name = &quot;packLevel_&quot; + recordCount;
elemPackLevel.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;);
elemPackType.add(elemOption);
elemOption = new Option(&quot;Type1&quot;,&quot;Type1&quot;);
elemPackType.add(elemOption);

elemOption2 = new Option(&quot;Select One&quot;,&quot;Select One&quot;);
elemPackLevel.add(elemOption2);
elemOption2 = new Option(&quot;Level1&quot;,&quot;Level1&quot;);
elemPackLevel.add(elemOption2);


//add the inputs to the appropriate cells
elemCols[0].appendChild(elemPackType);
elemCols[1].appendChild(elemPackLevel);



//add the cols to the row
elemRow.appendChild(elemCols[0]);
elemRow.appendChild(elemCols[1]);


//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
//End Dynamic Form
//-->
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top