How do I create Text Fields on the fly?

I’m creating a simulation that allows the user to select items from a 3D product catalogue. I’ve set up a series of arrays that sorts unique and identical items into groups with a text field where a price can be added to calculate some totals. My problem is that a user can select any number of items, even hundreds if they so choose. Is there a way to adjust the number of text fields based on the number of items chosen? Right now I’m using a finite switch statement:

  function GUITextFieldSwitcher(){
			GUILayout.BeginVertical();//End the automatic vertical layout
			GUILayout.BeginHorizontal();//End the automatic horizontal layout
 			switch (i7) {
				case 0 :
			   		stringToEdit0  = GUILayout.TextField (stringToEdit0, 5, GUILayout.Width(50));

“+” “+PriceCalc00.ToString(), mySkin20);
var temp0 : float = 0.0f;
if (stringToEdit0 != “”){
if (float.TryParse(stringToEdit0, temp0)){
PriceCalc00 = Mathf.Clamp(0.00, temp0, PriceCalc00) * pickDuplicateNumber;
case 1 :
stringToEdit1 = GUILayout.TextField (stringToEdit1, 5, GUILayout.Width(50));
“+” "+PriceCalc01.ToString(), mySkin20);
var temp1 : float = 0.0f;
if (stringToEdit1 != “”){
if (float.TryParse(stringToEdit1, temp1)){
PriceCalc01 = Mathf.Clamp(0.00, temp1, PriceCalc01) * pickDuplicateNumber;

etc, etc, etc. This approach would require a case for each possible item and, therefore, a unique text field variable for each, otherwise the user can’t type in unique prices in each field. Is there a way to create text fields on the fly so that I don’t have to set up such an immense switch statement?

I’m not sure about what exactly you’re trying to do, but if you have a variable number of items maybe a couple of builtin arrays and a for loop can do the job - something like this:

var stringToEdit: String[];
var PriceCalc: float[];
var nItens: int = 0;

// call this function to initialize the arrays to "quant" elements
function LoadItems(quant: int){
    stringToEdit = new String[quant];
    PriceCalc = new float[quant];
    nItens = quant;
    // assign the stringToEdit and PriceCalc elements here

function GUITextFields(){
  GUILayout.BeginVertical();//Start the automatic vertical layout
  for (var i = 0; i < nItems; i++){
    stringToEdit _= GUILayout.TextField (stringToEdit*, 5, GUILayout.Width(50));*_
   "+"    "+PriceCalc*.ToString(), mySkin20);*_
 _if (stringToEdit *!= ""){*_
 _*var temp : float = 0.0f; // no need to have different temp temporary variables*_
 _if (float.TryParse(stringToEdit*, temp)){*_
 PriceCalc = Mathf.Clamp(0.00, temp, PriceCalc_) * pickDuplicateNumber;_ 
 _*GUILayout.EndVertical();//End the automatic vertical layout*_