Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2012
    residenza
    Bologna
    Messaggi
    38

    Convalida di un input in tabella

    Buondi, ho un problemino che mi assilla da qualche giorno.

    Spero in un vostro aiuto .

    Ho un tabella html con dati prelevati dal mio database. Uno dei campi di questa tabella viene aggiornato con una modifica in linea tramite ajax.

    Tutto funziona al meglio, tranne la convalida dell'input.

    Questo è il codice jquery:

    codice:
    jQuery(document).ready(function()
    {
    jQuery(".edit_tr").click(function()
    {
    var ID=jQuery(this).attr('id');
    jQuery("#first_"+ID).hide();
    jQuery("#first_input_"+ID).show();
    }).change(function()
    {        
    var ID=jQuery(this).attr('id');
    var first=jQuery("#first_input_"+ID).val();
    var dataString = 'id='+ ID +'&lottery='+first;
    jQuery("#first_"+ID).html('<img src="images/loading.gif" />'); 
    
    jQuery(".editbox").each(function() {
        blottery=jQuery(this).val(); 
       
    if((first.length>0) && (blottery<90))  
    
    {
    jQuery.ajax({
    type: "POST",
    url: "scripts/table_edit.php",
    data: dataString,
    cache: false,
    success: function(html)
    {
    jQuery("#first_"+ID).html(first);
    }
    });
    }
    else
    {
    alert('Errore');
    }
    });
    });
    
    jQuery(".editbox").mouseup(function()
    {
    return false
    });
    
    jQuery(document).mouseup(function()
    {
    jQuery(".editbox").hide();
    jQuery(".text").show();
    });
    
    });
    Il problema accade al momento della convalida del valore; se digito un numero maggiore di 90 mi viene segnalato l'errore ma l'aggiornamento va ugualmente a buon fine.

    Come posso risolvere?

  2. #2
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    cos'è .editbox e come è tag form?
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  3. #3
    Utente di HTML.it
    Registrato dal
    Feb 2012
    residenza
    Bologna
    Messaggi
    38
    Quote Originariamente inviata da cavicchiandrea Visualizza il messaggio
    cos'è .editbox e come è tag form?
    Il tag form non c'è. Editbox è l'input:

    Codice PHP:
    <table class="dataTable" style="white-space: nowrap">
        <tr class="title">
        <th rowspan="1" colspan="1" class="first-head">Nome</th>
        <th rowspan="1" colspan="1" class="head">Posizione</th>
        <th rowspan="1" colspan="1" class="head">Overall</th>
        <th rowspan="1" colspan="1" class="head">Lotto</th>
        </tr>
        <?php do {
                     
        
    $id=$row_viewteamcoach['id'];
        
    $lottery=$row_viewteamcoach['playerLottery'];?>
       
        <tr id="<?php echo $id?>" class="edit_tr">
        <td class="table0"><?php echo $row_viewteamcoach['playerName'];?></td>
        <td class="table1"><?php echo $row_viewteamcoach['playerPosition'];?></td>
        <td class="table1"><span class="labelov"><?php echo $row_viewteamcoach['playerOverall']; ?></span></td>
        <td class="table1"><span id="first_<?php echo $id;?>" class="text"><?php echo $lottery?></span>
        <input size="1" maxlength="2" type="text" value="<?php echo $lottery;?>" class="editbox" id="first_input_<?php echo $id?>"/><img style="cursor:pointer" src="images/inline_edit.png" width="15" height="15"/></td>
        </tr>
        <?php } while ($row_viewteamcoach mysql_fetch_assoc($viewteamcoach)); ?>
        </table>

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.