[JS] Formular

eugenb

Member
ID: 229385
L
25 April 2006
14
0
Hi leude ich will immo ein Fomular machn in dem man erst eine sache auswählt und dann erst kommen weiter auswahl möglichkeiten unso ,

also nur kommt da ein fehler den ich mir nicht erklären kann^^ , wenn man jez eine sache auswählt sollten die anderen sachn angezeigt werden nur wird irgendwie eine <tr> nicht geschlossen obwohl alle </tr> vorhanden sind -.- naja vllt könnt ihr mir helfn

formular:
HTML:
<script language="javascript" src="formular.js" type="text/javascript"></script>
<form action="index.php?p=auftrag" method="post">
<table cellspacing="0" cellpadding="0" border="0">
    <tr>
        <th colspan="2">Vorab:</th>
    </tr>
    
    <tr>
        <td colspan="2">
        <strong>Info</strong><br>

Bitte wählen sie aus, ob ihr Projekt komerziell ist oder einen Privaten Zweck verfolgt.<br><br>

Beachten sie auch unsere AGB, welche Sie <a href="index.php?p=agb">hier</a> nachlesen können.
        </td>
    </tr>
    
    <tr>
        <td>Zweck</td><td><input type="radio" name="typ" value="privat" onclick="javascript:zweck(this.value)">Privat    <input type="radio" name="typ" value="komerziell" onclick="javascript:zweck(this.value)">Komerziell</td>
    </tr>
    
    <tr>
        <td colspan="2">   </td>
    </tr>
    
    <tr>
        <th colspan="2">Informationen der Internetpräsenz</th>
    </tr>
    <tr>
        <td>Adresse:</td><td><input type="text" name="adresse" size="20" value="https://"></td>
    </tr>
    
    <tr>
        <td>Script:</td>
        <td><input type="radio" name="script_abfrage" value="selbst_erstelltes_script">Selbst erstelltes Script<input type="radio" name="script_abfrage" value="kosten_script">Kostenloses/-pflichtiges Script</td>
    </tr>
    
    <tr style="display: none;" id="script_url">
        <td style="display: none;" id="script_url_inhalt">Seite des Erstellers:</td>
        <td style="display: none;" id="script_url_inhalt2"><input name="script_url" type="text" value="https://" size="20"></td>
    </tr>
    
    <tr style="display: none;" id="info_space">
        <td colspan="2" style="display: none;" id="info_space_inhalt">   </td>
    </tr>
    
    <tr style="display: none;" id="info_person_h">
        <th colspan="2" style="display: none;" id="info_person_h_inhalt">Informationen zur Person</th>
    </tr>
    
    <tr style="display: none;" id="info_firma_h">
        <th colspan="2" style="display: none;" id="info_firma_h_inhalt">Informationen zur Firma</th>
    </tr>
    
    <tr style="display: none;" id="info_person">
        <td style="display: none;" id="info_person_inhalt">Ihr Vor- und Nachname:</td>
        <td style="display: none;" id="info_person_inhalt2"><input name="name" type="text" size="20"></td>
    </tr>
    
    <tr style="display: none;" id="info_firma">
        <td style="display: none;" id="info_firma_inhalt">Name der Firma:</td>
        <td style="display: none;" id="info_firma_inhalt2"><input name="name" type="text" size="20"></td>
    </tr>
    
    <tr style="display: none;" id="info_firma_fax">
        <td style="display: none;" id="info_firma_fax_inhalt">Fax-Nr.</td>
        <td style="display: none;" id="info_firma_fax_inhalt2"><input type="text" name="fax" size="20"></td>
    </tr>
    
    <tr style="display: none;" id="info_email">
        <td style="display: none;" id="info_email_inhalt">Email: </td>
        <td style="display: none;" id="info_email_inhalt2"><input type="text" name="email" size="20"></td>
    </tr>
    
    <tr style="display: none;" id="info_person_icq">
        <td style="display: none;" id="info_person_icq_inhalt">ICQ: </td>
        <td style="display: none;" id="info_person_icq_inhalt2"><input type="text" name="icq" size="9"></td>
    </tr>
    
</table>
</form>
formular.js:
PHP:
function zweck (which) {
    if(which=="privat")
        {
            document.getElementById('info_space').style.display = 'inline';
            document.getElementById('info_person_h').style.display = 'inline';
            document.getElementById('info_person').style.display = 'inline';
            document.getElementById('info_email').style.display = 'inline';
            document.getElementById('info_person_icq').style.display = 'inline';
            document.getElementById('info_firma_h').style.display = 'none';
            document.getElementById('info_firma').style.display = 'none';
            document.getElementById('info_firma_fax').style.display = 'none';
            //Inhalt^^
            document.getElementById('info_space_inhalt').style.display = 'inline';
            document.getElementById('info_person_h_inhalt').style.display = 'inline';
            document.getElementById('info_person_inhalt').style.display = 'inline';
            document.getElementById('info_person_inhalt2').style.display = 'inline';
            document.getElementById('info_email_inhalt').style.display = 'inline';
            document.getElementById('info_email_inhalt2').style.display = 'inline';
            document.getElementById('info_person_icq_inhalt').style.display = 'inline';
            document.getElementById('info_person_icq_inhalt2').style.display = 'inline';
            document.getElementById('info_firma_h_inhalt').style.display = 'none';
            document.getElementById('info_firma_inhalt').style.display = 'none';
            document.getElementById('info_firma_inhalt2').style.display = 'none';
            document.getElementById('info_firma_fax_inhalt').style.display = 'none';
            document.getElementById('info_firma_fax_inhalt2').style.display = 'none';
        }
    else if(which=="komerziell")
        {
            document.getElementById('info_space').style.display = 'inline';
            document.getElementById('info_person_h').style.display = 'none';
            document.getElementById('info_person').style.display = 'none';
            document.getElementById('info_email').style.display = 'inline';
            document.getElementById('info_person_icq').style.display = 'none';
            document.getElementById('info_firma_h').style.display = 'inline';
            document.getElementById('info_firma').style.display = 'inline';
            document.getElementById('info_firma_fax').style.display = 'inline';
            //Inhalt^^
            document.getElementById('info_space_inhalt').style.display = 'inline';
            document.getElementById('info_person_h_inhalt').style.display = 'none';
            document.getElementById('info_person_inhalt').style.display = 'none';
            document.getElementById('info_person_inhalt2').style.display = 'none';
            document.getElementById('info_email_inhalt').style.display = 'inline';
            document.getElementById('info_email_inhalt2').style.display = 'inline';
            document.getElementById('info_person_icq_inhalt').style.display = 'none';
            document.getElementById('info_person_icq_inhalt2').style.display = 'none';
            document.getElementById('info_firma_h_inhalt').style.display = 'inline';
            document.getElementById('info_firma_inhalt').style.display = 'inline';
            document.getElementById('info_firma_inhalt2').style.display = 'inline';
            document.getElementById('info_firma_fax_inhalt').style.display = 'inline';
            document.getElementById('info_firma_fax_inhalt2').style.display = 'inline';
        }
}
Online Beispiel: https://www.eugen-bolz.de/formular/

Hoffe Ihr findet die Lösung^^

Mfg,
Eugen
 
Bei einem tr solltest du schon display: block nehmen sonst ist der Zeilenumbruch weg, mal davon absehn das sich sowas mit Tabellen von vonr herein blöd macht.
 
nur kann der IE mit den den table-css-Eigenschaften nichts anfangen, wie man an dem selfhtml Beispiel mal wieder sieht.