java si php
Last Updated: Jul 29 2005 14:58, Started by
andySF
, Jul 04 2005 15:47
·
0
#1
Posted 04 July 2005 - 15:47
<? include ('config.php'); ?> <html> <head> <title></title> <script type="text/javascript" language="Javascript"> function TotalCheckedValues() { var total = 0; if(document.F2.hard.checked == true) { total += parseFloat(document.F2.hard.value); } if(document.F2.soft.checked == true) { total += parseFloat(document.F2.soft.value); } if(document.F2.retea.checked == true) { total += parseFloat(document.F2.retea.value); } if(document.F2.internet.checked == true) { total += parseFloat(document.F2.internet.value); } var ts = new String(total); if(ts.indexOf('.') < 0) { ts += '.00'; } if(ts.indexOf('.') == (ts.length - 2)) { ts += '0'; } document.F2.T.value = ts; } </script> <style type="text/css"> <!-- .style1 { font-family: Georgia, "Times New Roman", Times, serif; font-weight: bold; font-size: 12px; } .tabel { border: thin solid #000000; background-color: #CCCCCC; padding: 10px; } .style2 { color: #333333; font-weight: bold; } --> </style> </head> <body> <? mysql_select_db("oferta"); $sql_main= "SELECT * FROM echipament"; $query_main=mysql_query($sql_main); while($row=mysql_fetch_array($query_main)) { ?> <table width="484" border="0" cellpadding="0" cellspacing="0" class="tabel"> <!--DWLayoutTable--> <tr> <td width="484" height="19" valign="top"><span class="style2">Denumire : <?=$row['denumire'];?> , Utilizator: <?=$row['utilizator'];?> </span></td> </tr> <tr> <td height="136" valign="top"> <? $sql_main1= "SELECT * FROM preturi"; $query_main1=mysql_query($sql_main1) or die('Tabela nu poate fi aleasa'); $row=mysql_fetch_array(mysql_query($sql_main1)); ?> <form name="F2"> <p> <input type="checkbox" name ="hard" value ="<?=$row['pret_hardware'];?>" onchange="TotalCheckedValues()" /> Hardware - Pret Service/Luna este <?=$row['pret_hardware'];?>$ <br/> <input type="checkbox" name ="soft" value ="<?=$row['pret_software'];?>" onchange="TotalCheckedValues()"/> Software - Pret Service/Luna este <?=$row['pret_software'];?>$<br/> <input type="checkbox" name ="retea" value ="<?=$row['pret_retea'];?>" onchange="TotalCheckedValues()"/> Retea - Pret Service/Luna este <?=$row['pret_retea'];?>$<br/> <input type="checkbox" name ="internet" value ="<?=$row['pret_internet'];?>" onchange="TotalCheckedValues()"/> Internet - Pret Service/Luna este <?=$row['pret_internet'];?>$<br> <span class="style1">Total:</span><br> <input type="text" name="T" readonly size="10" /> exprimat in $ fara TVA </p> </form></td> </tr> <tr> <td height="151" valign="top">Descriere: <?=$row['descriere']; ?></td> </tr> </table><br /> <? } ?> </body> </html> Salut, dupa cum vedeti mai sus acel form afisa adunarea valorilor checkbox-urilor intr-un textbox (asta cand nu era while) adika pe mine ma intereseasa sa afiseze realtime valorile checkbox-urilor adunate ... cand am pus while....java cred pierde notiunea variabilelor si nu mai afiseaza nimik... ma puteti ajuta? sau imi puteti spune alta metoda de lucru ? merci |
#3
Posted 05 July 2005 - 08:03
da omule ma refer la java script, :death: :death: :death: scuza-ma.... :death: si nu la javascript in general ci la cel din sursa de mai sus....:) multumesc
chiar trebuie sa fac chestia asta....nu are nimeni o idee? |
#4
Posted 29 July 2005 - 14:52
daca n-ai rezolvat-o inca cred ca am io o idee :)
problema e simpla ... tu accesezi checkboxurile dupa nume...si inainte sa bagi while - ul normal ca mergea... da acum in while nu mai ai un singur checkbox cu numele hard de exemplu ...ci vei avea mai multe...iar in momentul cand accesezi dupa nume va intoarce o colectie nu un checkbox :) daca tot le pui dinamic baga la ele si numele dinamic ... |
#5
Posted 29 July 2005 - 14:58
while($row=mysql_fetch_array($query_main)) { [.....] $sql_main1= "SELECT * FROM preturi"; $query_main1=mysql_query($sql_main1) or die('Tabela nu poate fi aleasa'); $row=mysql_fetch_array(mysql_query($sql_main1)); ?> Din cate vad eu se pierde acel while din cauza ca variabila $row isi pierde valoarea initiala cand atribui al doilea mysql_fetch_array Later edit: damn! nu m-am uitat cand s-a deschis topicul :confuzzled: Edited by MadMax, 29 July 2005 - 15:01. |
Anunturi
Bun venit pe Forumul Softpedia!
▶ 0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users