Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [js]formularz bez nazwy, problem
piczu
post
Post #1





Grupa: Zarejestrowani
Postów: 182
Pomógł: 0
Dołączył: 4.01.2005
Skąd: piczu.info

Ostrzeżenie: (10%)
X----


mam taka strone:
  1. <form action="" method="POST">
  2. ..
  3. <button type="button" onclick='tag()'></button>
  4. ..
  5. <div class="row">
  6. <div class="cell2">
  7. <textarea rows="6" wrap="soft" name="text1"></textarea>
  8. </div>
  9. </div>
  10. ..
  11. </form>


oraz funkcje js
  1. function tag() {
  2. tekst = prompt("");
  3. if ( (tekst != null) && (tekst != "") ) {
  4. form.text1.value += tekst;
  5. }
  6. }


jednak przycisk mi nie dziala
dopiero jak dam nazwe formularzowi oraz zmienie funkcje js
  1. nazwa.text1.value += tekst;

, ale ja nie chce nadawac form nazwy. co robie nie tak (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post
Zajec
post
Post #2





Grupa: Zarejestrowani
Postów: 1 086
Pomógł: 8
Dołączył: 10.12.2003

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


Poprawne odwołanie:

Kod
document.form['name'].elements['name'].value

lub
Kod
document.form[nr].elements[nr].value



ad 2.
nr to numer formularza wg.występowania w kodzie strony (zaczynamy numerować od zera)
Go to the top of the page
+Quote Post
revyag
post
Post #3





Grupa: Przyjaciele php.pl
Postów: 2 258
Pomógł: 16
Dołączył: 21.09.2004
Skąd: Kielce

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


Można to zrobić też nadając id dla textarea. A w funkcji zamienić
Kod
nazwa.text1.value += tekst;

na
Kod
document.getElementById(id_textarea).value+=tekst;
Go to the top of the page
+Quote Post
piczu
post
Post #4





Grupa: Zarejestrowani
Postów: 182
Pomógł: 0
Dołączył: 4.01.2005
Skąd: piczu.info

Ostrzeżenie: (10%)
X----


robie
  1. document.form[0].elements['text1'].value

i
  1. document.getElementById(text1).value


nic nie dziala (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)
Go to the top of the page
+Quote Post
revyag
post
Post #5





Grupa: Przyjaciele php.pl
Postów: 2 258
Pomógł: 16
Dołączył: 21.09.2004
Skąd: Kielce

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


Kod
document.getElementById("text1").value;

  1. <textarea rows="6" wrap="soft" id="text1" name="text1"></textarea>

Musi działać (IMG:http://forum.php.pl/style_emoticons/default/snitch.gif)
Go to the top of the page
+Quote Post
nospor
post
Post #6





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




poza tym powinnno być document.forms[0] anie document.form[0]
Go to the top of the page
+Quote Post
piczu
post
Post #7





Grupa: Zarejestrowani
Postów: 182
Pomógł: 0
Dołączył: 4.01.2005
Skąd: piczu.info

Ostrzeżenie: (10%)
X----


nareszcie mi dziala (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) THX wszystkim
Go to the top of the page
+Quote Post

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: 22.08.2025 - 15:15