Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2011
    Messaggi
    65

    selezione automatica checkbox

    ciao a tutti,
    sto cercando di far si che quando clicco nel campo input si seleziona automaticamente il checkbox.
    Il problema è che indipendentemente dall'input in cui clicco si seleziona soltanto il primo checkbox. Allego l'immagine per una maggiore chiarezza e il codice HTML


    codice HTML:
    <tr>
    <td class="list-ID" style="text-align:center"><?php echo $productID; ?></td>
    <td class="list-ID" style="width: 15px !important;padding-right:5px; text-align:right"><input type="checkbox" id="check" name="productEdit[]" style="width:13px; height:13px" /></td>
    <td class="list-NA">
    <input type='hidden' name='list-ID[]' value='<?php echo $productID; ?>'/>
    <input class="list-NA" type="text" maxlength="50" style="width:100%;" name="productName[]" onfocus="document.getElementById('check').checked=true" value="<?php echo $productNA;?>" />
    </td>
    <td class="list-DE">
    <input class="list-DE" type="text" maxlength="50" style="width:100%;" name="productDesc[]" onfocus="document.getElementById('check').checked=true" value="<?php echo $productDE;?>" />
    </td>
    </tr>
    Immagini allegate Immagini allegate

  2. #2
    Utente di HTML.it
    Registrato dal
    Apr 2000
    Messaggi
    938
    Ma se dai a tutti i check lo stesso nome è logico che qualsiasi campo clicchi ti abiliti quello chiamato check

    codice:
    <input type="checkbox" id="check" name="productEdit[]" style="width:13px; height:13px" />
    
    associato a
    
    onfocus="document.getElementById('check').checked=true"
    
    <input type="checkbox" id="check1" name="productEdit[]" style="width:13px; height:13px" />
    
    associato a
    
    onfocus="document.getElementById('check1').checked=true"
    
    <input type="checkbox" id="check2" name="productEdit[]" style="width:13px; height:13px" />
    
    associato a
    
    onfocus="document.getElementById('chec2').checked=true"
    Massimo.

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 © 2025 vBulletin Solutions, Inc. All rights reserved.