Autor Zpráva
Peter45
Profil
Neviem mozna divne,ale mam kosik kde je konecna suma,plus formular na vyplnenie objednavky a ten obsahuje select kde je este postovne.Po oznaceni tohto postovneho sa mi vsak kosik neprepocita...ako na to aby sa mi prepocital?
tiso
Profil
Javascript, AJAX alebo po odoslaní formulára zobraziť novú cenu aj s poštovným.
Joker
Profil
Peter45:
Neviem mozna divne
eh... cože?

ako na to aby sa mi prepocital?
A je na stránce skript, který to při změně hodnoty v políčku přepočítá?
Peter45
Profil

<form name="form2" method="post" action="?art=kosik.php&amp;action=odoslat" >
<? 
$variabilny = $sUserID.createRandomVariabilny();

$variabilny = substr($variabilny, 0, 8);
$_SESSION['sVariabilny'] = $variabilny;



?>

          <table  border="0" cellpadding="2" cellspacing="1">
           
            <tr>
              <td width="150"><strong>*Meno a priezvisko:</strong></td>
              <td width="410"><input name="meno" type="text" id="meno" value="<? echo $zaznam[meno]?>" class="text" ></td>
            </tr>
            <tr>
              <td><strong>*Adresa:</strong></td>
              <td><input  class="text"  name="ulica" type="text" id="ulica" value="<? echo $zaznam[adresa]?>" ></td>
            </tr>
            <tr>
              <td><strong>*Mesto:</strong></td>
              <td><input  class="text"  name="mesto" type="text" id="mesto" value="<? echo $zaznam[mesto]?>" ></td>
            </tr>
            <tr>
              <td><strong>*PSČ:</strong></td>
              <td><input  class="text" name="psc" type="text" id="psc" value="<? echo $zaznam[psc]?>" ></td>
            </tr>
            <tr>
              <td><strong>E-mail:</strong></td>
              <td><input  class="text"  name="email" type="text" id="email" value="<? echo $zaznam[email]?>" ></td>
            </tr>
            <tr>
              <td><strong>*Telefón:</strong></td>
              <td><input class="text"   name="telefon" type="text" id="telefon" value="<? echo $zaznam[telefon]?>" ></td>
            </tr>
			
            <tr>
              <td>Spôsob platby </td>
              <td><script type="text/javascript">
			  function check()
			  {
			 
			if (document.form2.platba.value=="Hotovosť (u nás v obchode)" )		document.form2.dorucenie.disabled=true;
			else document.form2.dorucenie.disabled=false;
			  }
			  </script>

			  
			 <select name="platba" id="platba" onchange="check();" style="width:225px" class="text">
                <option value="Dobierka (pošta)" >Dobierka (pošta)</option>
                <option value="Dobierka (UPS)" >Dobierka (UPS)</option>
                <option value="Hotovosť (u nás v obchode)">Hotovosť (u nás v obchode)</option>
                <option value="Prevodom (proforma)">Prevodom (proforma)</option>
              </select></td>
            </tr>
            <tr>
              <td>Doručenie</td>
              <td><select name="dorucenie" id="dorucenie" style="width:225px" >
                <option value="Osobne (u nás v obchode)">Osobne (u nás v obchode)</option>
                <option value="Slovenská pošta (Slovensko 3,319,- EUR)">Slovenská pošta (Slovensko 3.319,- EUR)</option>
                <option value="UPS do 24hod. Slovensko 8,298,- EUR" selected="selected">UPS do 24hod. Slovensko 8,298,- EUR</option>
              </select></td>
            </tr>
            <tr>
              <td><strong>Poznámka</strong></td>
              <td><textarea name="poznamka" class="fta"  id="poznamka" rows="4" cols="20"></textarea></td>
            </tr>
            <tr>
              <td valign="top"><strong>Suma na úradu </strong></td>
              <td>
                <?   echo number_format($totalcena*1.19, 2, ',', ' ')." &euro;"; ?><br >
<span class="small"><? echo number_format($totalcena*1.19*$_SESSION["sEuro"] , 1, ',', ' '); ?>0 Sk</span>
              </td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>			  </td>
            </tr>
                    <tr>
      <td valign="top">&nbsp;</td>
      <td valign="top"><a href="podmienky.php" target="_blank"><b>Obchodn&eacute; podmienky</b></a>
     <br> <div style="margin-top: 5px; font-size:12px; font-weight:bold; color: #000;"><input name="podmienky" type="checkbox" id="podmienky" value="2" />  Súhlasím s obchodnými podmienkami 
     </div> </td>
    </tr>
            <!--  <tr>
      <td valign="top">&nbsp;</td>
      <td valign="top"><h4>
          <input name="podmienky" type="checkbox" id="podmienky" value="2" />  Súhlasím s obchodnými podmienkami    </h4></td>
    </tr>  -->

            
            <tr>
              <td>&nbsp;</td>
              <td> <br>
<input value="Objednať" style="font-size: 10pt; color: #FFF; font-weight: bold; border: 1px solid #222; background-color: #F00FCE;"  type="submit"  name="submit" class="button">
 
           <!--   <button class="button" type="submit" name="submit">Objednať</button> -->
              <input name="objed" type="hidden" id="objed" value="2" >
		<input name="sumauhrada" type="hidden" value="<? echo $totalcena*1.19; ?>"  >
              </td>
            </tr>
           
            <tr>
              <td colspan="2" class="small"><br>Všetky položky označené * sú povinné. </td>
            </tr>
  </table>
        
</form>



Peter45
Profil
A toto je kod z kosika:



<?php


// if (!$logged) @mysql_query("delete from kosik where cookieid = '" . KosikId() . "' ");


switch($_GET["action"])
{
case "add":
{
// addprod($_GET["id"], $_GET["pocet"]);
ukazkosik();
break;
}
case "update":
{
// updateprod($_GET["id"], $_GET["pocet"]);
ukazkosik();
break;
}
case "remove":
{
// removeprod($_GET["id"]);
ukazkosik();
break;
}
case "objednat":
{
$totalcena=ukazkosik();
if (!$totalcena) { error ("Košík prázdny"); break; }
include "objednat.php";

break;
}
case "odoslat":
{

if (!$meno || !$ulica || !$mesto || !$podmienky || !$psc):
error("Nevyplnili ste všetky potrebné údaje", "");
include "objednat.php";
$stop=true;
endif;

if (!$stop):
$textmail=objednavka_tabulka();

$ok=mailer ($email, $textmail, "Objednavka", "$shopreplyaddress");


removeall();
$suma=$sumauhrada;
message("Objednávka odoslaná", );
endif;

break;
}
default:
{
ukazkosik();
}
}




function createRandomVariabilny() {

$chars = "0123456789";
srand((double)microtime()*1000000);
$i = 0;
$rpass = '';

while ($i <= 16) {
$num = rand(0,10);
$tmp = substr($chars, $num, 1);
$rpass = $rpass . $tmp;
$i++;
}
return $rpass;
}



function objednavka_tabulka()
{
global $meno, $ulica, $mesto, $psc, $email, $telefon, $fax, $platba, $dorucenie, $poznamka, $sVariabilny, $sUser, $sSkupina, $sUserID;


$casnow=Time();

$totalcena = 0;
$sqlQ = "select * from kosik inner join tovar on kosik.produktid = tovar.id where kosik.cookieid = '" . KosikId() . "' order by tovar.nazov asc";



$result = mysql_query($sqlQ);

$textstart = "<h1>Objednavka</h1>";
$texttable = "<table width=\"100%\" border=\"1\" cellspacing=\"1\" cellpadding=\"1\"> \n";

$texttable = $texttable . "<tr>

<td>Nazov</td>
<td>Cena s DPH</td>
<td>Kusov</td>
<td>Celkom</td>

</tr>";
//
while($row = mysql_fetch_array($result))
{
if ($row["akcia"] && $row["cena2"]) $row["cena"]=$row["cena2"];


$totalcena += $row["pocet"] * $row["cena"]*1.19;

$texttable = $texttable . "
<tr>
<td>$row[nazov]</td>
<td>".$row[cena]*1.19." &euro; <br >".round($row[cena]*1.19/$_SESSION["sEuro"],2)." Sk</td>
<td>$row[pocet]</td>
<td>";
$celkom=$row["pocet"] * $row["cena"]*1.19 ;
$celkomeuro=round($row["pocet"] * $row["cena"]*1.19/$_SESSION["sEuro"],2);
$texttable.=" $celkom &euro; <br > $celkomeuro Sk</td>
</tr>";


$kurzeuro=$_SESSION["sEuro"];

$sql=" INSERT INTO objednavky VALUES ('', '$row[id]', '$row[nazov]', '$row[pocet]', '$celkom', '$meno', '$ulica', '$mesto', '$psc', '$email', '$telefon', '$kurzeuro', '$platba', '$dorucenie', '$poznamka','$casnow', '0', '$sUserID', '$koefsql', '$sVariabilny' )";

$ins = MySQL_Query($sql);
if (!$ins) echo "CHYBA ".mysql_error();
}

$texttable.="</table>";



$totalcenadph=round($totalcena,2);
$totalcenadpheuro=round($totalcena/$_SESSION["sEuro"],2);


$textend = "<br>
Cena spolu: <strong>$totalcenadph &euro; </strong> s DPH<br><br>\n

Meno: $meno<br>\n
Adresa: $ulica<br>\n
Mesto: $mesto PSC: $psc<br><br>\n\n
Email: $email<br>\n
Telefon: $telefon <br><br>\n

Poznamka: $poznamka<br>\n
Sposob platby: $platba<br>\n
Dorucenie: $dorucenie<br><br>\n\n";

if ($dorucenie=="Slovenská pošta (Slovensko 100,- Sk)") $textend = $textend . " + poštovné 100 Sk Slovenská pošta <br >\n";
if ($dorucenie=="UPS do 24hod. Slovensko 250,- Sk") $textend = $textend . " + poštovné 250 Sk UPS do 24hod. Slovensko <br >\n";





$text = $textstart. $texttable. $textend;

return $text;


}

function ukazkosik()
{
global $sSkupina,$euro;
?>

<h1>Košík</h1>
<?
echo "<div style=\"padding:4px;\">";

$totalcena = 0;
$sqlQ = "select * from kosik inner join tovar on kosik.produktid = tovar.id where kosik.cookieid = '" . KosikId() . "' order by tovar.nazov asc";


$result = mysql_query($sqlQ);
?>
<form name="frmCart" method="post" action="">
<table width="100%" class="sample">
<tr>
<th width="39"><strong>Počet</strong></th>
<th><strong>Produkt</strong></th>
<th width="76"><strong>Cena</strong></th>
<th width="100"><strong>Celkom</strong></th>
<th width="16">&nbsp;</th>
</tr>

<?php
while($row = mysql_fetch_array($result))
{
// zjistí celkovou cenu


if ($row["akcia"] && $row["cena2"]) $row["cena"]=$row["cena2"];

$totalcena += $row["pocet"] * $row["cena"];
?>
<tr>
<td valign="top" >
<select name="<?php echo $row["id"]; ?>" onchange="updatepocet(this)">
<?php
$list=$row["pocet"]+9;

for ($i = 1; $i <= $list; $i++)
{
echo "<option ";
if ($row["pocet"] == $i) echo " selected=\"selected\" ";
echo ">" . $i . "</option>";
}
?>
</select></td>
<td valign="top" ><strong><a class="bigger" href="?art=detail.php&amp;id=<? echo $row["id"] ?>"><? echo $row["nazov"]; ?></a></strong> </td>
<td valign="top" >
<?php echo number_format( $row["cena"]*1.19 , 2, ',', ' '); ?> &euro;<br >
<span class="small"><? echo number_format($row["cena"]*1.19*$_SESSION["sEuro"] , 1, ',', ' '); ?>0 Sk</span> </td>
<td valign="top" ><?php $celkom=$row["pocet"] * $row["cena"]*1.19; echo number_format( $celkom , 2, ',', ' '); ?> &euro;<br >
<span class="small"><? echo number_format($row["pocet"] * $row["cena"]*1.19*$euro , 1, ',', ' '); ?>0 Sk</span> </td>
<td valign="top" >
<a href="?art=kosik.php&amp;action=remove&amp;id=<?php echo $row["id"]; ?>"><img src="images/delete.gif" alt="Vymazať z košíka" title="Vymazať z košíka" border="0" ></a> </td>
</tr>
<?
}
?>
</table>
</form>
<br >

<div class="kosikfinal">

<h1>Suma na úhradu: <u><? echo number_format($totalcena*1.19, 2, ',', ' '); ?></u> &euro;</h1>
<span class="smaller">Suma na úhradu: <u><? echo number_format($totalcena*1.19*$_SESSION["sEuro"] , 1, ',', ' '); ?></u>0 Sk</span></div>
<span class="smaller">Všetky ceny sú vrátane DPH. </span><br >
<? if ($_POST["action"]!="odoslat" && $_POST["action"]!="objednat" && $totalcena): ?>

<br >

<form name="cnt" method="post" action="?art=kosik.php&amp;action=objednat">
<input value="Objednávka" style="font-size: 10pt; color: #FFFF

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm: