Salve ragazzi, dopo tante consultazioni nel forum non ho ancora risolto il mio problema.
Io ho due menu a tendina con select che vengono riempite da record raccolti da un db Access. Fino a qui tutto bene. Il problema sta che nel secondo menu a tendina vorrei che i record vengano stampati con un massimo di 100 caratteri. Vi posto il codice Js che ho posto tra i tag <head> </head>:
Nel tag <body> ho inserito questo comando:codice:<script type="text/javascript" language="javascript"> //<![CDATA[ url = ""; d = document; preloadText = "Generazione dati in corso....."; function caricaPagina(pagina,idLayer) { if (d.getElementById) {var x=(window.ActiveXObject)?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();} if (x) { d.getElementById(idLayer).innerHTML = preloadText; x.onreadystatechange = function() { if (x.readyState == 4 && x.status == 200) { el=d.getElementById(idLayer);el.innerHTML = x.responseText; } } x.open("GET", url + pagina, true); x.send(null); } } function checkForm() { var ilForm = d.forms[0]; var err = true; var l1 = document.getElementById("Error1"); var l2 = document.getElementById("Error2"); l1.style.display = "none";l2.style.display= "none"; if (ilForm.CodCategoriaMerceologica.value == "") { l1.style.display = "block";l1.innerHTML = "E' necessario selezionare una Categoria Merceologica."; err = false; } if (ilForm.CodCategoriaPrincipale.value == "") { l2.style.display = "block";l2.innerHTML= "E' necessario selezionare una Sottocategoria."; err = false; } return err; } //]]> </script> <script type="text/javascript"> <!-- var cod=new Array(); cod[0]=new Array("Seleziona una Sottocategoria"); cod[1]=new Array(<% Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/mdb-database/fornitori.mdb") sql = "SELECT * from categorieprincipali WHERE Codice=1" Set Rs = Server.CreateObject("ADODB.Recordset") Rs.Open sql, Conn, 1, 3 testo = Rs("DescrCategoriaPrincipale") testo = Left(testo, 100) RecordsPerPage = 100 Page = Request.QueryString("page") If Len(page) > 0 And IsNumeric(page) Then page = CLng(page) Else Page = 1 End If If Rs.EOF Then Response.Write "<option value="">Nessun dato presente</option>" Else Rs.PageSize = RecordsPerPage Rs.AbsolutePage = Page For x = 1 To RecordsPerPage If not rs.eof then Response.write testo Rs.MoveNext End If Next End If Rs.Close Set Rs = Nothing Conn.Close Set Conn = Nothing %>"Altro..............."); cod[2]=new Array(<% Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/mdb-database/fornitori.mdb") sql = "SELECT * from categorieprincipali WHERE Codice=2" Set Rs = Server.CreateObject("ADODB.Recordset") Rs.Open sql, Conn, 1, 3 testo1 = Rs("DescrCategoriaPrincipale") testo1 = Left(testo1, 100) RecordsPerPage = 100 Page = Request.QueryString("page") If Len(page) > 0 And IsNumeric(page) Then page = CLng(page) Else Page = 1 End If If Rs.EOF Then Response.Write "<option value="">Nessun dato presente</option>" Else Rs.PageSize = RecordsPerPage Rs.AbsolutePage = Page For x = 1 To RecordsPerPage If not rs.eof then Response.write testo1 Rs.MoveNext End If Next End If Rs.Close Set Rs = Nothing Conn.Close Set Conn = Nothing %>"Altro..............."); function Riempi(source) { with (document.operatori.CodCategoriaPrincipale) { while (options.length > 0) options[0]=null; for (i=0;i<cod[source].length;i++) options[i]=new Option(cod[source][i]) options.selectedIndex=0; } } //--> </script>
che richiama la selezione dei dati nella pagina che contiene la connessione al db.codice:onload="caricaPagina('db.asp?type=CodCategoriaMerceologica','AHAH_1');"
Alla fine ho nel corpo le due select:
Il problema sta nel fatto che i dati della seconda select mi si visionano per intero e non secondo la limitazione dei 100 caratteri. Ho evidenziato le due select. In rosso la prima e in blu la seconda.codice:1) <div id="AHAH_1"> <select name="CodCategoriaMerceologica"> <option value=""> seleziona una Categoria Merceologica </option></select></div> 2) <div id="AHAH_2"> <select name="CodCategoriaPrincipale"> <option value="">seleziona una Sottocategoria </option></select></div>
![]()


Rispondi quotando
