eGospodarka.pl
eGospodarka.pl poleca

eGospodarka.plGrupypl.comp.wwwzmienna liczba pól formularzazmienna liczba pól formularza
  • Data: 2009-07-07 14:51:31
    Temat: zmienna liczba pól formularza
    Od: Mossy <m...@g...com> szukaj wiadomości tego autora
    [ pokaż wszystkie nagłówki ]

    Witam serdecznie,

    potrzebuje formularz, w którym zależnie od liczby wybranej z menu
    select (1 do 5) aktywna będzie odpowiednia liczba pól na wpisanie np.
    nazwika i numeru telefonu. Odpowiednio dla jednej osoby po jednym
    polu, dla 5 osób po pięć pól.

    Poniższy kod działa pod FF i Opera, a nie chce działać dla IE.
    Uprzejmie proszę o pomysły, co zrobić aby w IE też działało oraz
    ewentualnie jak to uprościć w ogóle.

    <form method="post" target="_blank" action="./plik.php">
    <div >
    <div align="left" style="float:left; width:40px">
    No.<br />
    <select name="quantity" tabindex="7" >
    <option value="1" onclick="document.getElementById
    ('person1').style.display = this.selected ? 'block' : 'none';
    document.getElementById
    ('person2').style.display = this.selected ? 'none' : 'block';
    document.getElementById
    ('person3').style.display = this.selected ? 'none' : 'block';
    document.getElementById
    ('person4').style.display = this.selected ? 'none' : 'block';
    document.getElementById
    ('person5').style.display = this.selected ? 'none' :
    'block';">1&nbsp;&nbsp;</option>

    <option value="2" onclick="document.getElementById
    ('person1').style.display = this.selected ? 'block' : 'none';
    document.getElementById
    ('person2').style.display = this.selected ? 'block' : 'none';
    document.getElementById
    ('person3').style.display = this.selected ? 'none' : 'block';
    document.getElementById
    ('person4').style.display = this.selected ? 'none' : 'block';
    document.getElementById
    ('person5').style.display = this.selected ? 'none' : 'block';
    this.form.elements
    ['student2'].disabled = this.form.elements['mobile2'].disabled = !
    this.selected;" >2&nbsp;&nbsp;</option>

    <option value="3" onclick="document.getElementById
    ('person1').style.display = this.selected ? 'block' : 'none';
    document.getElementById
    ('person2').style.display = this.selected ? 'block' : 'none';
    document.getElementById
    ('person3').style.display = this.selected ? 'block' : 'none';
    document.getElementById
    ('person4').style.display = this.selected ? 'none' : 'block';
    document.getElementById
    ('person5').style.display = this.selected ? 'none' : 'block';
    this.form.elements
    ['student2'].disabled = this.form.elements['mobile2'].disabled =
    this.form.elements['student3'].disabled = this.form.elements
    ['mobile3'].disabled = !this.selected" >3&nbsp;&nbsp;</option>

    <option value="4" onclick="document.getElementById
    ('person1').style.display = this.selected ? 'block' : 'none';
    document.getElementById
    ('person2').style.display = this.selected ? 'block' : 'none';
    document.getElementById
    ('person3').style.display = this.selected ? 'block' : 'none';
    document.getElementById
    ('person4').style.display = this.selected ? 'block' : 'none';
    document.getElementById
    ('person5').style.display = this.selected ? 'none' : 'block';
    this.form.elements
    ['student2'].disabled = this.form.elements['mobile2'].disabled =
    this.form.elements['student3'].disabled = this.form.elements
    ['mobile3'].disabled = this.form.elements['student4'].disabled =
    this.form.elements['mobile4'].disabled = !this.selected"
    >4&nbsp;&nbsp;</option>

    <option value="5" onclick="document.getElementById
    ('person1').style.display = this.selected ? 'block' : 'none';
    document.getElementById
    ('person2').style.display = this.selected ? 'block' : 'none';
    document.getElementById
    ('person3').style.display = this.selected ? 'block' : 'none';
    document.getElementById
    ('person4').style.display = this.selected ? 'block' : 'none';
    document.getElementById
    ('person5').style.display = this.selected ? 'block' : 'none';
    this.form.elements
    ['student2'].disabled = this.form.elements['mobile2'].disabled =
    this.form.elements['student3'].disabled = this.form.elements
    ['mobile3'].disabled = this.form.elements['student4'].disabled =
    this.form.elements['mobile4'].disabled = this.form.elements
    ['student5'].disabled = this.form.elements['mobile5'].disabled = !
    this.selected" >5&nbsp;&nbsp;</option>
    </select>
    </div>
    <div align="left" style="float:left; width:350px">
    <div align="center" style="float:left; width:
    160px">First &amp Last Name</div><div>Mobile No.</div>
    <div id="person1">
    <input type="text" name="student1" tabindex="8">
    <input type="text" name="mobile1" value="08*******1"
    tabindex="9">
    </div>
    <div id="person2" style="display: none">
    <input type="text" name="student2" tabindex="10"
    disabled="disabled" />
    <input type="text" name="mobile2" value="08*******2"
    tabindex="11" disabled="disabled" />
    </div>
    <div id="person3" style="display: none">
    <input type="text" name="student3" tabindex="12"
    disabled="disabled" />
    <input type="text" name="mobile3" value="08*******3"
    tabindex="13" disabled="disabled" />
    </div>
    <div id="person4" style="display: none">
    <input type="text" name="student4" tabindex="14"
    disabled="disabled" />
    <input type="text" name="mobile4" value="08*******4"
    tabindex="15" disabled="disabled" />
    </div>
    <div id="person5" style="display: none">
    <input type="text" name="student5" tabindex="16"
    disabled="disabled" />
    <input type="text" name="mobile5" value="08*******5"
    tabindex="17" disabled="disabled" />
    </div>
    </div>

    </div>
    </form>

Podziel się

Poleć ten post znajomemu poleć

Wydrukuj ten post drukuj


Następne wpisy z tego wątku

Najnowsze wątki z tej grupy


Najnowsze wątki

Szukaj w grupach

Eksperci egospodarka.pl

1 1 1

Wpisz nazwę miasta, dla którego chcesz znaleźć jednostkę ZUS.

Wzory dokumentów

Bezpłatne wzory dokumentów i formularzy.
Wyszukaj i pobierz za darmo: