Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Przekazywanie zmiennych do pola html
Foxim
post
Post #1





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 8.08.2013

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


Witam,

Od dłuższej chwili borykam się z problemem i proszę was o pomoc.

Mam taki kod:
  1.  
  2.  
  3. <script language="javascript">
  4. function check (skill){
  5. if(parseInt (document.getElementById("SP").value) > 0)
  6. add(skill);
  7. else
  8. alert("U don't have skills points!");
  9. }
  10. function add (skill){
  11. if(skill < 101)
  12. alert("dziala");
  13. else if(skill > 100 && skill < 126)
  14. alert("dziala");
  15. else if(skill >125 && skill < 151)
  16. alert("dziala");
  17. else if(skill > 150 && skill < 176 )
  18. alert("dziala");
  19. else if(skill >175 && skill < 201)
  20. alert("dziala");
  21. else if(skill > 200 && skill < 301)
  22. alert("dziala");
  23. else
  24. return;
  25. }
  26.  
  27. <input type='text' class="stats" id='SP' value='5' readonly="yes" > </h1>
  28. Klik <input type='text' class='skills' id="OUT" value='20' readonly="yes" > %
  29. <input type='button' class="skills" name='add' onclick='check(OUT.value)' value='+'/>
  30. <input type='button' class="skills" name='subtract' onclick='check(OUT.value)' value='-'/></p></h3>
  31.  
  32. </body>
  33. </html>


I wszystko działa problem polega pojawia się gdy chcę uzyskać coś takiego:
  1.  
  2. }
  3. function add (skill){
  4. if(skill < 101)
  5. skill = skill +1;
  6. return skill;
  7. else if(skill > 100 && skill < 126)
  8. alert("dziala");
  9. else if(skill >125 && skill < 151)
  10. alert("dziala");
  11. else if(skill > 150 && skill < 176 )
  12. alert("dziala");
  13. else if(skill >175 && skill < 201)
  14. alert("dziala");
  15. else if(skill > 200 && skill < 301)
  16. alert("dziala");
  17. else
  18. return;
  19. }



Chodzi o to aby funkcja zwracała wartość zmiennej do pola(w tym przypadku OUT) z której uzyskała wartość.
Nie mogę użyć getElementById("") (w taki sposób jaki ja potrafie jej użyć) gdyż dla każdego przypadku musiałbym tworzyć osobną funkcje.

Pozdrawiam.
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: 5.10.2025 - 20:56