-
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 </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 </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 </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 </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 </option>
</select>
</div>
<div align="left" style="float:left; width:350px">
<div align="center" style="float:left; width:
160px">First & 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>
Następne wpisy z tego wątku
- 07.07.09 23:08 Paweł Piskorz
- 07.07.09 23:30 rezist.com
Najnowsze wątki z tej grupy
- Jakie znacie działające serwery grup dyskusyjnych?
- is it live this group at news.icm.edu.pl
- php, linki z nazwami a $_GET, SEO
- www polityka pl captcha
- dyktatura brudnego palucha
- www.znanylekarz.pl
- Czy pytanie o sczytywanie stron programami/skryptami to tu?
- Grupy webdevowe
- Jak wydrukować stronę?
- IIS, kilka witryn
- linki <a href="/strona.php"> (ze slashami)
- co rozszerza stronę??
- responsywny akapit <p>
- Czy istnieje jakiś emulator przeglądarek pod Mac'a?
- taka sama konfiguracja dla localhost i produkcji
Najnowsze wątki
- 2024-11-08 Belka
- 2024-11-09 pierdolec na punkcie psa
- 2024-11-09 Warszawa => Sales Executive <=
- 2024-11-09 Wrocław => SAP BTP Consultant (mid/senior) <=
- 2024-11-09 Warszawa => ECM Specialist / Consultant <=
- 2024-11-09 Warszawa => Senior Frontend Developer (React + React Native) <=
- 2024-11-10 TVN donosi: Obywatelskie zatrzymanie policjanta (nie na służbie)
- 2024-11-08 Warszawa => Head of International Freight Forwarding Department <=
- 2024-11-08 Warszawa => Key Account Manager <=
- 2024-11-08 Szczecin => Key Account Manager (ERP) <=
- 2024-11-08 Białystok => Full Stack web developer (obszar .Net Core, Angular6+) <
- 2024-11-08 Wrocław => Senior PHP Symfony Developer <=
- 2024-11-08 Warszawa => QA Engineer <=
- 2024-11-08 Warszawa => QA Inżynier <=
- 2024-11-08 Warszawa => Key Account Manager <=