Visualizzazione dei risultati da 1 a 7 su 7
  1. #1

    convertire funzione checkbox in select

    ciao, ho bisogno di un'aiuto
    vorrei modificare questa funzione in modo che nel form appaia un campo select anzichè tanti checkbox
    grazie

    $i = 0;

    foreach ($this->serverList as $value) {

    if ($value['check'] == true) $checked=" checked='checked' ";

    else $checked = " ";



    echo '<td><input type="checkbox" name="tld_'.$value['tld'].'"'.$checked.' />.'.$value['tld'].'</td>';

    $i++;

    if ($i > 4) {

    $i = 0;

    echo '</tr><tr>';
    Bono

  2. #2
    per ora ho fatto così ma mi crea tanti select quanti sono i dati che richiama, come faccio a far mettere tutti i dati in un solo select?
    function tldListH(){

    $i = 0;

    foreach ($this->serverList as $value) {

    if ($value['check'] == true) $checked=" checked='checked' ";

    else $checked = " ";



    echo '<td><select name="tld_'.$value['tld'].'"'.$checked.'><option value='.$value['tld'].'>'.$value['tld'].'</option></select></td>';

    $i++;

    if ($i > 4) {

    $i = 1;

    echo '</tr><tr>';

    }

    }



    }
    Bono

  3. #3
    Utente di HTML.it L'avatar di bstefano79
    Registrato dal
    Feb 2004
    Messaggi
    2,520
    il tag select mettilo fuori dal ciclo e il ceched va sulloption non sulla select
    Codice PHP:
    $i 0;
    echo 
    "<tr><td><select name=\"tld_$value['tld']\">";
    foreach (
    $this->serverList as $value) {

    if (
    $value['check'] == true$checked=" checked='checked' ";

    else 
    $checked " ";



    echo 
    "<option value=\"".$value['tld']."\" $checked>".$value['tld']."</option>";

    $i++; 

    if (
    $i 4) {

    $i 1;

    }
    echo 
    "</select></td></tr>";
    }





  4. #4
    grazie mille era proprio quello che volevo, solo che ora ho un altro problema

    messo così quando effetuo la ricerca non funziona, il form viene inviato ma non genera risultati

    function tldListH(){

    $i = 0;
    echo '<tr><td><select name="tld_'.$value['tld'].'"'.$checked.'">';

    foreach ($this->serverList as $value) {

    if ($value['check'] == true) $checked=" checked='checked' ";

    else $checked = " ";


    echo '<option value='.$value['tld'].'>'.$value['tld'].'</option>';

    $i++;

    if ($i > 100) {

    $i = 1;

    echo '</select></td><t/r>';

    }

    }


    }

    se invece cambio posizione alla riga
    echo '<tr><td><select name="tld_'.$value['tld'].'"'.$checked.'">';

    il form genera risultati ma mi appaiono tanti select quanti sono i campi del select

    function tldListH(){
    $i = 0;
    foreach ($this->serverList as $value) {
    if ($value['check'] == true) $checked=" checked='checked' ";
    else $checked = " ";
    echo '<tr><td><select name="tld_'.$value['tld'].'"'.$checked.'">';
    echo '<option value='.$value['tld'].'>'.$value['tld'].'</option>';
    $i++;
    if ($i > 100) {
    $i = 1;
    echo '</select></td><t/r>';
    }
    }
    }
    Bono

  5. #5
    ok, risolto, ho modificato la stringa

    echo '<tr><td><select name="tld_'.$value['tld'].'"'.$checked.'">';

    con

    echo '<tr><td><select name="tld_com>';

    ora funziona regolarmente

    grazie per l'aiuto
    Bono

  6. #6
    Utente di HTML.it L'avatar di bstefano79
    Registrato dal
    Feb 2004
    Messaggi
    2,520
    non capisco che errore hai... prova a postare anche il codice dove recuper i dati della form

  7. #7
    Utente di HTML.it L'avatar di bstefano79
    Registrato dal
    Feb 2004
    Messaggi
    2,520
    ops hai risposto prima, prego

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.