• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

Textfeld zeigen durch Checkbox

alfl

Neues Mitglied
Hallo Liebe Forumwelt,

ich habe auf dem Formular auf www.f-i-s.ch/tmp/new.php flgendes Problem, die auswahlliste bei Prospekte soll nur angezeigwerden wenn CB aktiv. Dies funktioniert auch, aber erst wenn sie einmal aktiviert und deaktiviert wird. Was muss ich da noch machen?

hier mein code:

HTML:
<input type="checkbox" name="Prospekt" onclick="autograedel.listeprospekt.style.display = this.checked == true ? 'block':'none';" />
      </td>
      <td>Senden Sie mir Prospekte
      <label for="listeprospekt"></label>
        <select name="listeprospekt" id="listeprospekt">
      </select>

Liebe Grüsse
 
Werbung:
Hallo,

Dein Formular enthält Fehler im HTML.
Wenn du die Checkbox von Anbeginn nicht angezeigt haben möchtest, musst diese unsichtbar machen.
Formulare mit Tabellen zu designen ist zwar möglich aber unschön.

Ich habe dir hier mal ein Beispiel erstellt wie es auch anders geht. Du kannst im CSS-Bereich fast alles im Stil verändern.
HTML:
<!DOCTYPE HTML>
<html>
<head>
   <meta charset=UTF-8>
   <title>Formular Beispiel in HTML und CSS</title>
   <meta name="description" content="Beispiel für ein Formular">

   <style type="text/css">
   body {
        margin:1em auto;
        width:50em;
    }
    h3 {
    }
   /* Formular */
    form {
    }
    fieldset {
        margin-top:15px;
        padding: 5px;
    }
    legend {
        background-color:lightblue;
    }
    input {
        display:block;
        color: green;
    }
    input[type="text"] {
        border:1px solid red;    
    }
    label {
        float: left;
        width: 5em;
        margin-left:10px;             
    }
    label.checkbox {
        width: 20em;
    }
    #listeprospekt {
        display:none;
    }
 }
   </style>

</head>

 <body>

    <h3>Schön, Sie in unserem Kundenkontakt-Programm zu begrüssen.</h3>
    <form id="form1" name="autograedel" method="post" action="">
    <fieldset id="kontaktdaten"><legend>Ihre Kontaktdaten</legend>
        <label for="Herr">Herr</label><input type="radio" name="Herr" value="Herr" />
        <label for="Frau">Frau</label><input type="radio" name="Frau" value="Frau" />
        <label for="Name">Name:</label><input type="text" name="Name"  />
        <label for="Vorname">Vorname:</label><input type="text" name="Vorname"  />
        <label for="Adresse">Adresse:</label><input type="text" name="Adresse" />
        <label for="plz">PLZ:</label><input type="text" name="plz" width="50px"/> 
        <label for="plz">Ort:</label><input type="text" name="ort" />
        <label for="E-Mail">E-Mail:</label></label><input type="email" name="E-Mail" />
        <label for="Telefon">Telefon:</label><input type="tel" name="Tel" />
    </fieldset>
    <fieldset id="wunsch"><legend>Bitte wählen Sie aus </legend>    <label class="checkbox" for="Anruf">Rufen Sie mich an, um mein Anliegen zu besprechen:</label><input type="checkbox" name="Anruf" />
        <label class="checkbox" for="Prospekte">Senden Sie mir Prospekte</label><input type="checkbox" name="Prospekt" onclick="autograedel.listeprospekt.style.display = this.checked == true ? 'block':'none';" />
        <label for="listeprospekt"></label>
        <select name="listeprospekt" id="listeprospekt">
            <option>CB3 </option>
            <option>ListeCB3 </option>
            <option>CB4 </option>
            <option>CB3 </option>
            <option>CB3 </option>
        </select>
    </fieldset>
    </form>

</body>

</html>
 
Zurück
Oben