-
1. Data: 2009-07-07 14:51:31
Temat: zmienna liczba pól formularza
Od: Mossy <m...@g...com>
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>
-
2. Data: 2009-07-07 23:08:29
Temat: [NTG] Re: zmienna liczba pól formularza
Od: Paweł Piskorz <n...@p...nie?>
Mossy pisze:
> 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.
Najpierw pl.comp.lang.php, teraz pl.comp.www, znajdziesz w końcu
pl.comp.lang.javascript? ;]
--
message[autor="PablO"]::after {
content:"Pozdrawiam";
}
-
3. Data: 2009-07-07 23:30:21
Temat: Re: [NTG] Re: zmienna liczba pól formularza
Od: "rezist.com" <r...@s...us>
> Najpierw pl.comp.lang.php, teraz pl.comp.www, znajdziesz w końcu
> pl.comp.lang.javascript? ;]
To ja pomoge!
<?
Header( "HTTP/1.1 301 Moved Permanently" );
header("Location:
http://groups.google.pl/group/pl.comp.lang.javascrip
t/topics");
exit;
?>
--
tomek nowak
http://rezist.com
http://anvilstrike.com
http://mylittlesecret.pl