Buongiorno a tutti
ho un problema.
Ho la necessità di creare dei campi select in modo dinamico all'interno di una form e caricarne i contenuti utilizzando ajax.
Il tutto sembra funzionare correttamente fino a che non faccio la submit: leggendo dalla request non trovo nessun valore relativo alle select generate.
Mi potete aiutare?
Di seguito il codice javascript per generare i select:
codice:function addRowToTable() { var tbl = document.getElementById('aipr'); var lastRow = tbl.rows.length; // if there's no header row in the table, then iteration = lastRow + 1 var iteration = lastRow; if (document.getElementById("active_ingr_id"+(iteration-1)).value != 0) { var row = tbl.insertRow(lastRow); //Active Ingredient var cell1 = row.insertCell(0); var div = document.createElement("div"); div.id = "activeIngrSel" + iteration; var sel = document.createElement('select'); sel.name = 'active_ingr_id' + iteration; sel.id = 'active_ingr_id' + iteration; sel.options[0] = new Option('-', '0'); sel.onchange=function(){loadProduct(this.value,0,iteration);} div.appendChild(sel); cell1.appendChild(div); //Product cell1 = row.insertCell(1); div = document.createElement("div"); div.id = "productSel" + iteration; sel = document.createElement('select'); sel.name = 'id_ai_pr' + iteration; sel.id = 'id_ai_pr' + iteration; sel.options[0] = new Option('-', '0'); div.appendChild(sel); cell1.appendChild(div); //Strength cell1 = row.insertCell(2); div = document.createElement("div"); div.id = "strenghtSel" + iteration; sel = document.createElement('select'); sel.name = 'strength_id' + iteration; sel.id = 'strength_id' + iteration; sel.options[0] = new Option('-', '0'); div.appendChild(sel); cell1.appendChild(div); //Route cell1 = row.insertCell(3); div = document.createElement("div"); div.id = "routeSel" + iteration; sel = document.createElement('select'); sel.name = 'route_id' + iteration; sel.id = 'route_id' + iteration; sel.options[0] = new Option('-', '0'); div.appendChild(sel); cell1.appendChild(div); //Form cell1 = row.insertCell(4); div = document.createElement("div"); div.id = "formSel" + iteration; sel = document.createElement('select'); sel.name = 'form_id' + iteration; sel.id = 'form_id' + iteration; sel.options[0] = new Option('-', '0'); div.appendChild(sel); cell1.appendChild(div); } return iteration; }

Rispondi quotando
