Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [HTML][PHP]Kalkulator w php
djjbenus
post
Post #1





Grupa: Zarejestrowani
Postów: 71
Pomógł: 0
Dołączył: 22.05.2010

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


Witam,

pisze kalkulator w php za pomocą formularza.

  1. <html>
  2. <head>
  3. <title>Kalkulator
  4. </title>
  5. </head>
  6. <body>
  7. <div id="">
  8. <form action="kalkulator.php" method="POST">
  9. <input type="text" name="model" title="wynik" size="12" value="0"/> <br /><br />
  10. <input class="submit" type="submit" name="submit" value="1" />
  11. <input class="submit" type="submit" name="submit" value="2" />
  12. <input class="submit" type="submit" name="submit" value="3" />
  13. <input class="submit" type="submit" name="submit" value="+" /> <br />
  14. <input class="submit" type="submit" name="submit" value="4" />
  15. <input class="submit" type="submit" name="submit" value="5" />
  16. <input class="submit" type="submit" name="submit" value="6" />
  17. <input class="submit" type="submit" name="submit" value="-" /> <br />
  18. <input class="submit" type="submit" name="submit" value="7" />
  19. <input class="submit" type="submit" name="submit" value="8" />
  20. <input class="submit" type="submit" name="submit" value="9" />
  21. <input class="submit" type="submit" name="submit" value="*" /> <br />
  22. <input class="submit" type="submit" name="submit" value=" , " />
  23. <input class="submit" type="submit" name="submit" value="0" />
  24. <input class="submit" type="submit" name="submit" value="=" />
  25. <input class="submit" type="submit" name="submit" value="/" />
  26. </form>
  27. </div>
  28. </body>
  29. </html>


Teraz mój problem. Otóż jak przekazać wartość przycisku do pola tekstowego na górze zarazem wykonując działania?

Z góry dzięki.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
peter13135
post
Post #2





Grupa: Zarejestrowani
Postów: 1 447
Pomógł: 191
Dołączył: 26.03.2008

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


Jak można pisać kalklulator w php za pomocą formularza ? (IMG:style_emoticons/default/tongue.gif)

Kod
<input class="submit" type="submit" name="submit" value="2" />

Te pola powinieneś generować w pętli

Cytat
Teraz mój problem. Otóż jak przekazać wartość przycisku do pola tekstowego na górze zarazem wykonując działania?


Za pomocą JS/jQuery.

robisz event onClick (w js) / click (w jquery) który odpala funkcję, która pobiera wartość przyciśniętego buttona i ustawia jakąś tam wartość w innym elemencie.
W js na pewno użyjesz funkcji getElementById() lub pokrewnej (byName, czy byClass)
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: 14.09.2025 - 20:50