Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Problemi con checkbox

  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2006
    Messaggi
    209

    Problemi con checkbox

    Salve a tutti

    ho un problema con delle check box in fase di modifica.
    In pratica mi salva solo il primo valore che trova impostato
    Mi spiego ho 5 check box che in fase di inserimento funzionano bene.
    Quando vado in modifica e provo a modificare alcune check, mi salva solo la prima.
    In pratica nel Request("check[]") che eseguo dopo l'Action del form trovo solo il primo, in sequenza, dei valori cambiati



    <script type="text/javascript">
    function checkUncheck(check)
    {
    var checks = document.getElementsByName('check[]');
    for(i = 0; i < checks.length; i++)
    {
    checks[i].checked = check.checked;
    }
    }
    </script>
    .....


    <form action="updutenti.asp?save=yes&amp;idutente=<%=id% >" method="post" name="srv">
    <div style="margin-left:10px ">Id Utente:
    <input disabled="disabled" maxlength=30 size=35 value="<%=id%>" style="font-family:tahoma; font-size:11px; margin-left:36px " name="idutente">
    </div>
    <div style="margin-left:10px ">Password:
    <input type="password" maxlength=30 size=30 value="<%=rs(5)%>" style="font-family:tahoma; font-size:11px; margin-left:28px " name="password" onblur="this.value=this.value.replace(/^\s*/,'')">
    </div>
    <div style="margin-left:10px ">Nome:
    <input type="text" maxlength=30 size=30 value="<%=rs(1)%>" style="font-family:tahoma; font-size:11px; margin-left:51px " name="nome" onblur="this.value=this.value.replace(/^\s*/,'')">
    </div>
    <div style="margin-left:10px ">Cognome:
    <input type="text" maxlength=30 size=30 value="<%=rs(2)%>" style="font-family:tahoma; font-size:11px; margin-left:33px " name="cognome" onblur="this.value=this.value.replace(/^\s*/,'')">
    </div>
    <div style="margin-left:10px ">Utente:
    <input disabled="disabled" type="text" maxlength=30 size=30 value="<%=trim(rs(3))%>" style="font-family:tahoma; font-size:11px; margin-left:47px " name="utente" onblur="this.value=this.value.replace(/^\s*/,'')">
    </div>

    <div style="margin-left:10px ">Reparto:
    <select size=1 style="font-family:tahoma; font-size:11px; margin-left:40px " name="reparto">
    <%
    dim RSReparti
    set RSReparti = Server.CreateObject("ADODB.RECORDSET")
    RSReparti.ActiveConnection=Objconn
    RSReparti.Open("Select * from T_Reparti")
    Response.Write("<option selected>"& reparto & "</option>")
    while not RSReparti.EOF
    if ucase(reparto)<> ucase(RSReparti(1)) then
    Response.Write "<option value=" & trim(RSReparti(0)) & ">" & RSReparti(1) & "</option>" & vbcrlf
    end if
    RSReparti.movenext
    wend
    RSReparti.close
    set RSReparti=nothing
    %>
    </select>
    </div>



    <div style="margin-left:10px ">Funzioni:



    <%
    if rs("Riparazioni")=True then
    %>
    <label for="myCheckbox1"><input type="checkbox" checked="checked" name="check[]" value="1">Riparazioni</label>
    <%
    else
    %>
    <label for="myCheckbox1"><input type="checkbox" name="check[]" value="1">Riparazioni</label>
    <%
    end if

    if rs("Produzioni")=True then
    %>
    <label for="myCheckbox2"><input type="checkbox" checked="checked" name="check[]" value="2">Produzioni</label>
    <%
    else
    %>
    <label for="myCheckbox2"><input type="checkbox" name="check[]" value="1">Produzioni</label>
    <%
    end if
    if rs("Report")=True then
    %>
    <label for="myCheckbox3"><input type="checkbox" checked="checked" name="check[]" value="3">Report</label>
    <%
    else
    %>
    <label for="myCheckbox3"><input type="checkbox" name="check[]" value="3">Report</label>
    <%
    end if

    if rs("Tabelle")=True then
    %>
    <label for="myCheckbox4"><input type="checkbox" checked="checked" name="check[]" value="4">Tabelle</label>
    <%
    else
    %>
    <label for="myCheckbox4"><input type="checkbox" name="check[]" value="4">Tabelle</label>
    <%
    end if

    if rs("Abilitazioni")=True then
    %>
    <label for="myCheckbox5"><input type="checkbox" checked="checked" name="check[]" value="5">Riparazioni</label>
    <%
    else
    %>
    <label for="myCheckbox5"><input type="checkbox" name="check[]" value="5">Riparazioni</label>
    <%
    end if
    %>


    <label for="myCheckboxAll"><input type="checkbox" onclick="checkUncheck(this);">Tutte</label>
    </div>


    </div>



    <table width="90%" border="0" cellspacing="0" cellpadding="0">


    <div style="height:1px; background-image:url(../immagini/dot1.jpg); margin-left:10px; margin-right:10px ">[img]../immagini/spacer.gif[/img]</div>



    <INPUT type="button" value="modifica" name="b1" onclick="Controlla()"><input type="Reset" Value="annulla" id=Reset1 name=Reset1>
    </table>
    </p>
    </form>


    Ogni consiglio è ben accetto.

    Grazie

  2. #2
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    1. Non capisco cosa centri il tuo problema con javascript?
    2. Perché chiami tutte le checkbox uguali?
    3. Il request("check[]") nella pagina updutenti.asp e un array (tipo chebox1,chebox2,etc....) e come tale va gestita
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

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.