Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2006
    Messaggi
    213

    select in una function javascript

    ciao a tutti,ho questa funzione javascript per aggiungere dinamicamente delle righe:
    codice:
    var cntRows=1;
    function AddRow() {
    	cntRows++
    	var cell=cntRows
    	var newcell="<input type=\"text\" name=\"riga"+"\" size=\"7\" value=\""+cell+"\">"
    	var newcell1=""
    	var newcell2var newcell2="<input type=\"text\" name=\"Articolo"+"\" size=\"20\">"			        
    	var newcell3=""
    	var newcell4="<input type=\"text\" name=\"qnt"+"\" size=\"10\">"
    	var newcell5=""
    	var newcell6="<input type=\"text\" name=\"prezzoU"+"\" size=\"10\">"
    	var newcell7=""
    	var newcell8="<input type=\"text\" name=\"prezzoT"+"\" size=\"10\">"
    	var newcell9=""
    	var newcell10="<input type=\"button\" name=\"B2"+"\" size=\"20\"  value=\"Inserisci Riga\" onclick=\"AddRow()\">"
    	var newcell11=""
    	var newcell12="<input type=\"button\" name=\"B3"+"\" size=\"20\" value=\"Elimina Riga\" onclick=\"DelRow()\">"			
    		
    	table.insertRow()
    	table.rows(table.rows.length-1).insertCell()
    	table.cells(table.cells.length-1).innerHTML=newcell
    	table.rows(table.rows.length-1).insertCell()
    	table.cells(table.cells.length-1).innerHTML=newcell1
    	table.rows(table.rows.length-1).insertCell()
    	table.cells(table.cells.length-1).innerHTML=newcell2
    	table.rows(table.rows.length-1).insertCell()
    	table.cells(table.cells.length-1).innerHTML=newcell3
    	table.rows(table.rows.length-1).insertCell()
    	table.cells(table.cells.length-1).innerHTML=newcell4
    	table.rows(table.rows.length-1).insertCell()
    	table.cells(table.cells.length-1).innerHTML=newcell5
    	table.rows(table.rows.length-1).insertCell()
    	table.cells(table.cells.length-1).innerHTML=newcell6
    	table.rows(table.rows.length-1).insertCell()
    	table.cells(table.cells.length-1).innerHTML=newcell7
    	table.rows(table.rows.length-1).insertCell()
    	table.cells(table.cells.length-1).innerHTML=newcell8
    	table.rows(table.rows.length-1).insertCell()
    	table.cells(table.cells.length-1).innerHTML=newcell9
    	table.rows(table.rows.length-1).insertCell()
    	table.cells(table.cells.length-1).innerHTML=newcell10
    	table.rows(table.rows.length-1).insertCell()
    	table.cells(table.cells.length-1).innerHTML=newcell11
    	table.rows(table.rows.length-1).insertCell()
    	table.cells(table.cells.length-1).innerHTML=newcell12
    }
    al posto di una text devo però mettere una select, che nel codice asp è:
    codice:
    <select size="1" name="Articolo" onchange="document.frmRicerca.prezzoU.value=articoloSelezionato(this);">
    	<option value=""></option>
    <%
                    do while not objRsProd.EOF
    %>
    	<option value="<%=objRsProd.fields("Code") & ";" & objRsProd.fields("RetailPrice")%>"><%= objRsProd.fields("Description") %></option>
    <%	
                    objRsProd.movenext 
                    loop
    	
    	objRsProd.close
    	objConn.close
    %>
    </select>
    come posso fare??

  2. #2
    Utente di HTML.it
    Registrato dal
    Oct 2006
    Messaggi
    213
    anche solo così non va:
    codice:
    var newcell2="<select size=\"1\" name=\"Articolo\" onchange=\"document.frmRicerca.prezzoU.value=articoloSelezionato(this);\">
            <option value=\"\"></option>
            <option value=\"ciao\"></option>
    </select>"

  3. #3
    Utente di HTML.it
    Registrato dal
    Oct 2006
    Messaggi
    213
    così va,ma ora il problema è popolarla

    var newcell2='<select size="1" name="Articolo"></select>';

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.