Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> select na input
Dex1987
post 30.10.2005, 19:07:32
Post #1





Grupa: Zarejestrowani
Postów: 246
Pomógł: 0
Dołączył: 28.09.2004

Ostrzeżenie: (0%)
-----


Witam,

chciałbym sie dowiedziec czy jest mozliwosc zamiany (bez przeladowania strony) pola select na pole input, a doklanie jak wybiore w polu select opcje inne to zmieni mi sie na inputa (text).

Jesli tak to porosil bym o jakis prosty przyklad, albo wskazówke.

Pozdrawiam dex.
Go to the top of the page
+Quote Post
ghostrider
post 30.10.2005, 19:19:39
Post #2





Grupa: Zarejestrowani
Postów: 135
Pomógł: 0
Dołączył: 30.09.2005
Skąd: k-rk

Ostrzeżenie: (0%)
-----


naprawde prosty przyklad:

  1. var textbox = "<input type=text value=''>";
  2. function doMe(elem)
  3. {
  4. if (elem.value=="other")
  5. {
  6. var div = document.getElementById("s");
  7. div.innerHTML = textbox;
  8. }
  9. }
  10. <div id=s>
  11. <select name=x onChange=doMe(this)>
  12. <option value=1> Good </option>
  13. <option value=2> No good </option>
  14. <option value=other> other </option>
  15. </select>
  16. </div>


Cytat
chciałbym sie dowiedziec czy jest mozliwosc zamiany (bez przeladowania strony) pola select na pole input, a doklanie jak wybiore w polu select opcje inne to zmieni mi sie na inputa (text).


mozliwosc jak widac jest, ale czy to dobre rozwiazanie ...
wedlug mnie nie, ale jak musisz ....


--------------------
There are 10 types of people in the world:
-Those who understand binary, and those who don't...
There's no place like 127.0.0.1
Go to the top of the page
+Quote Post
Dex1987
post 30.10.2005, 19:46:27
Post #3





Grupa: Zarejestrowani
Postów: 246
Pomógł: 0
Dołączył: 28.09.2004

Ostrzeżenie: (0%)
-----


Dzieki wielkie, wszystko działa. A jeszcze jakbyś mógł napisać dlaczego według Ciebie jest to złym rozwiązaniem?
Go to the top of the page
+Quote Post
ghostrider
post 30.10.2005, 20:00:29
Post #4





Grupa: Zarejestrowani
Postów: 135
Pomógł: 0
Dołączył: 30.09.2005
Skąd: k-rk

Ostrzeżenie: (0%)
-----


według mnie:
<złe>
- trzeba zadbac by uzytkownik mógł zmnienić zdanie i ponownie
wyswietlic <select>'a
"CO SI STALO z SELECTEM KTÓRY TU PRZED CHWILA BYL questionmark.gif"

- specyfikacje WAI www.w3c.org/wai (to obszerny temat)

- ponowny render już zaladowanej strony (przegladarki NIE musza tege robic)

</złe>

<dobre>
select + "jeśli inne to :" + pole textbox
</dobre>


--------------------
There are 10 types of people in the world:
-Those who understand binary, and those who don't...
There's no place like 127.0.0.1
Go to the top of the page
+Quote Post
Dex1987
post 31.10.2005, 12:55:16
Post #5





Grupa: Zarejestrowani
Postów: 246
Pomógł: 0
Dołączył: 28.09.2004

Ostrzeżenie: (0%)
-----


To bedzie wykorzystywane w panelu adm i tylko czasami.

Pojawil mi sie problem z tym:

zmienna $_POST[''] jest pusta jak zmienie na inputa (jak jest select to dziala dobrze)

Ten post edytował Dex1987 31.10.2005, 12:55:57
Go to the top of the page
+Quote Post
ghostrider
post 31.10.2005, 13:04:25
Post #6





Grupa: Zarejestrowani
Postów: 135
Pomógł: 0
Dołączył: 30.09.2005
Skąd: k-rk

Ostrzeżenie: (0%)
-----


<script>
var textbox = "<input type=text value='' name=x>";

.....

brakowalao paremetru name na polu text, ale myslalem ze sie zorietujesz ..


--------------------
There are 10 types of people in the world:
-Those who understand binary, and those who don't...
There's no place like 127.0.0.1
Go to the top of the page
+Quote Post
Dex1987
post 31.10.2005, 14:41:28
Post #7





Grupa: Zarejestrowani
Postów: 246
Pomógł: 0
Dołączył: 28.09.2004

Ostrzeżenie: (0%)
-----


Problem w tym ze sie zorientowalem i dopisalem, ale dalej nie dziala.
Go to the top of the page
+Quote Post
ghostrider
post 31.10.2005, 14:48:41
Post #8





Grupa: Zarejestrowani
Postów: 135
Pomógł: 0
Dołączył: 30.09.2005
Skąd: k-rk

Ostrzeżenie: (0%)
-----


nie wiem, u mnie działa. Oczywiście dodałem <form method=post .... >
  1. <? print_r($_POST); ?>
  2. var textbox = "<input type=text value='' name=x>";
  3. function doMe(elem)
  4. {
  5. if (elem.value=="other")
  6. {
  7. var div = document.getElementById("s");
  8. div.innerHTML = textbox;
  9. }
  10. }
  11. <form name="f" method="post">
  12. <div id=s>
  13. <select name=x onChange=doMe(this)>
  14. <option value=1> Good </option>
  15. <option value=2> No good </option>
  16. <option value=other> other </option>
  17. </select>
  18. </div>
  19. <input type="submit" name="go" value="go" />
  20. </form>


i jest OK zamienia i wysyla


--------------------
There are 10 types of people in the world:
-Those who understand binary, and those who don't...
There's no place like 127.0.0.1
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 24.04.2024 - 16:57