Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JavaScript] Przenoszenie <input> do drugiego <form>
lubiemdziem
post 15.07.2012, 11:39:16
Post #1





Grupa: Zarejestrowani
Postów: 28
Pomógł: 0
Dołączył: 13.06.2008

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


To co było wcześniej jest nieaktualne, pojawił się kolejny problem:
http://jsfiddle.net/cuB9y/9/

Mianowicie pogubiłem się w skrypcie i nie wiem jak go rozwiązać. Trzeci input powinien dodawać wartości dwóch wcześniejszuch inputów a tego nie robi.

Wcześniej wyglądało to tak: http://jsfiddle.net/cuB9y/7/

Ten post edytował lubiemdziem 15.07.2012, 12:27:03
Go to the top of the page
+Quote Post
bpskiba
post 15.07.2012, 12:33:30
Post #2





Grupa: Zarejestrowani
Postów: 340
Pomógł: 49
Dołączył: 3.07.2009
Skąd: Rzeszów

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


  1. <script languange="JavaScript" type="text/javascript">
  2.  
  3. function licz(x)
  4. {
  5. var Lancuch = new Array('0','0','83','174','276','388','512','650','801','969','1154','1358','1584','1833','2107','2411','2746','3115','3523','3973','4470','5018','5624','6291','7028','7842','8740','9730','10824','12031','13363','14833','16456','18247','20224','22406','24815','27473','30408','33648','37224','41171','45529','50339','55649','61512','67983','75127','83014','91721','101333','111945','123660','136594','150872','166636','184040','203254','224466','247886','273742','302288','333804','368599','407015','449428','496254','547953','605032','668051','737627','814445','899257','992895','1096278','1210421','1336443','1475581','1629200','1798808','1986068','2192818','2421087','2673114','2951373','3258594','3597792','3972294','4385776','4842295','5346332','5902831','6517253','7195629','7944614','8771558','9684577','10692629','11805606','13034431','200000000') ;
  6. document.getElementById("dane2").value=Lancuch[document.getElementById("dane1").value];
  7.  
  8. document.getElementById("dane3").value = parseFloat(document.getElementById("dane1").value) + parseFloat(document.getElementById("dane2").value);
  9. }
  10.  
  11. function dwa(x)
  12. {
  13. var Lancuch = new Array(0,0,83,174,276,388,512,650,801,969,1154,1358,1584,1833,2107,2411,2746,3115,
    3523,3973,4470,5018,5624,6291,7028,7842,8740,9730,10824,12031,13363,14833,16456,1
    8247,20224,22406,24815,27473,30408,33648,37224,41171,45529,50339,55649,61512,6798
    3,75127,83014,91721,101333,111945,123660,136594,150872,166636,184040,203254,22446
    6,247886,273742,302288,333804,368599,407015,449428,496254,547953,605032,668051,73
    7627,814445,899257,992895,1096278,1210421,1336443,1475581,1629200,1798808,1986068
    ,2192818,2421087,2673114,2951373,3258594,3597792,3972294,4385776,4842295,5346332,
    5902831,6517253,7195629,7944614,8771558,9684577,10692629,11805606,13034431,200000
    000) ;
  14. var b=0;
  15. while(Lancuch[b]<document.getElementById("dane2").value)
  16. b++;
  17. document.getElementById("dane1").value=(b-1);
  18. }
  19.  
  20. function trzy()
  21. {
  22. alert("?questionmark.gif");
  23. }
  24.  
  25. </script>
  26.  
  27. </head>
  28. <form>
  29. <input id="dane1" type="text" name="dane1" onkeyup="licz(this.form)" maxlength="2">+
  30. <input id="dane2" type="text" name="dane2" onkeyup="dwa(this.form)" maxlength="9">=
  31. </form>
  32.  
  33. <form>
  34. <input id="dane3" name="wynik" type="text" onkeyup="trzy()">
  35. </form>
  36. </body>
  37. </html>
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: 15.07.2025 - 17:12