Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript] Dynamiczne tworzenie kolejnych pól formularza, po kliknięciu [+] dodaje się owe pole <input>
Athlan
post
Post #1





Grupa: Developerzy
Postów: 823
Pomógł: 12
Dołączył: 18.12.2005

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


Cześć, generalnie chodzi mi o to, aby po naciśnięciu linku + dodawało się kolejne pole formularza, np:
  1. <input type="text" name="pole[]"><br />

po naciśnięciu plusa trzykrotnie dynamicznie stworzą się kolejne nowe pola jedno pod drugim:
  1. <input type="text" name="pole[]"><br />
  2. <input type="text" name="pole[]"><br />
  3. <input type="text" name="pole[]"><br />
  4. <input type="text" name="pole[]"><br />


macie namiary na jakieś gotowe skrypty lub (lepiej (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) ) jak napisać takie coś samemu (chodzi o generalną strukturę kodu i funkcje, których powinienem użyć, no i w jaki sposób mają się tworzyć nowe pola bo document.write() nie działa (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) )?

pozdrawiam (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
-Gość-
post
Post #2





Goście







Ja to mam tak:
w head:
  1. function _show( strValue )
  2. {
  3. if ( strValue == "inny" )
  4. {
  5. document.getElementById( 'jakies_id' ).style.display = 'block';
  6. }
  7. else
  8. {
  9. document.getElementById('jakies_id').innerHTML = '';
  10. document.getElementById( 'jakies_id' ).style.display = 'none';
  11. }
  12. }

a w body:
  1. <option value="inny" onclick="_show( this.value );" style="font-weight: bold; "> Inny </option>
  2. <input type="text" id="jakies_id" size ="30" maxlenght="30" name="jakis_name" style="display: none;" value="Wpisz nazwisko wykladowcy" />

Teraz jak w select'cie wybierzesz na inny to pojawi sie nowy input. Oczywiscie mozesz to przerobic po swojemu.
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 7.10.2025 - 13:42