| Autor | Zpráva | ||
|---|---|---|---|
| honzonator Profil * |
#1 · Zasláno: 5. 6. 2007, 08:32:41
ahoj, muze mi prosim nekdo vysvetlit proc mi nejde nasledujici javascript:
<html> <head> <script> function calculate(price,total,quantity){ var quantity var total quantity = document.getElementById(quantity).value; total = quantity*price; alert(total); document.getElementById(total_price_8).value = total; } </script> <head> <body> <table border="1"> <tr> <th>ID</th> <th>Type</th> <th>Name</th> <th colspan='2'>Price</th> <th>Image</th> <th>Quantity</th> <th></th> <th>Total</th> </tr> <tr> <td>8</td> <td>fruit</td> <td>apple</td> <td width='30px'>2.60</td> <td width='30px'>per kg</td> <td width='100px' height='100px'> <img src='IMAGES/PRODUCTS/apple.jpg'></td> <td><input type='text' style='width:40px' id='quantity_8'></td> <td><input type='button' value='ADD!' style='width:50px' onClick="calculate(2.60,'total_price_8','quantity_8')"></td> <td><input type='text' style='width:80px' id='total_price_8'></td> </tr> </table> </body> </html> ten alert tam mam jen proto, abych zjistil jestli to pocita. Dekuju Honzik |
||
| Hugo Profil |
#2 · Zasláno: 5. 6. 2007, 08:42:57
<html>
<head> <script> function calculate(price,total,quantity){ quantity = document.getElementById(quantity).value; total = quantity*price; alert(total); document.getElementById('total_price_8').value = total; } </script> <head> <body> <table border="1"> <tr> <th>ID</th> <th>Type</th> <th>Name</th> <th colspan='2'>Price</th> <th>Image</th> <th>Quantity</th> <th></th> <th>Total</th> </tr> <tr> <td>8</td> <td>fruit</td> <td>apple</td> <td width='30px'>2.60</td> <td width='30px'>per kg</td> <td width='100px' height='100px'> <img src='IMAGES/PRODUCTS/apple.jpg'></td> <td><input type='text' style='width:40px' id='quantity_8'></td> <td><input type='button' value='ADD!' style='width:50px' onClick="calculate(2.60,'total_price_8','quantity_8')"></td> <td><input type='text' style='width:80px' id='total_price_8'></td> </tr> </table> </body> </html> |
||
| honzonator Profil * |
#3 · Zasláno: 5. 6. 2007, 08:49:33
dikes,
ty uvozovky by me meli kopat pokazdy kdyz je vynecham |
||
| honzonator Profil * |
#4 · Zasláno: 5. 6. 2007, 08:58:55
Vlastne jinak, ten total musi zustat takhle, protoze si to id automaticky generuje php. No a ja myslel, ze kdyz to mam ve funkci definovany jako total, tak to tak muzu dat i do document.get......
<html> <head> <script> function calculate(price,total,quantity){ var quantity var total quantity = document.getElementById(quantity).value; total = quantity*price; document.getElementById(total).value = total; } </script> <head> <body> <table border="1"> <tr> <th>ID</th> <th>Type</th> <th>Name</th> <th colspan='2'>Price</th> <th>Image</th> <th>Quantity</th> <th></th> <th>Total</th> </tr> <tr> <td>8</td> <td>fruit</td> <td>apple</td> <td width='30px'>2.60</td> <td width='30px'>per kg</td> <td width='100px' height='100px'> <img src='IMAGES/PRODUCTS/apple.jpg'></td> <td><input type='text' style='width:40px' id='quantity_8'></td> <td><input type='button' value='ADD!' style='width:50px' onClick="calculate(2.60,'total_price_8','quantity_8')"></td> <td><input type='text' style='width:80px' id='total_price_8'></td> </tr> </table> </body> </html> |
||
| Hugo Profil |
#5 · Zasláno: 5. 6. 2007, 09:01:58
honzonator
To nepoběží, používáš jednu proměnnou na dvě různé věci (jako id prvku a jako celkovou cenu). |
||
| honzonator Profil * |
#6 · Zasláno: 5. 6. 2007, 09:12:53
Nejaky doporuceni?
|
||
| honzonator Profil * |
#7 · Zasláno: 5. 6. 2007, 09:20:52
Jsem pitomej, ingnoruj prosim predchozi otazku. Proste zmenit jmeno pole preci :)
|
||
| honzonator Profil * |
#8 · Zasláno: 5. 6. 2007, 09:46:27
muzu se jeste zeptat, jak omezim ten vysledek jan na dve desetiny mista?
|
||
|
Časová prodleva: 19 let
|
|||
0