Jump to content
Sign in to follow this  
Iceman.

php code

Recommended Posts

Salut. Am urmatorul script:

<html>

<head>

<script type="text/Javascript" language="JavaScript">

//

produse = new Array();

produse[0] = new Array('Televizor',300);

produse[1] = new Array('Computer', 500);

produse[2] = new Array('Masina',1500);

produse[3] = new Array('Napolitane',1.5);

produse[4] = new Array('Dulap 2 usi',150);

produse[5] = new Array('Auto Q7',100000);

// end produse

function caltot()

{

var tott = 0;

var totx = 0;

for (i=0;i<produse.length;i++)

{

var pret = parseFloat(document.getElementById('pret'+i.toString()).value);

var cant = parseInt(document.getElementById('cant'+i.toString()).value);

document.getElementById('cant'+i.toString()).value = cant;

totx = pret*cant;

tott += totx;

document.getElementById('val'+i.toString()).value = totx.toString();

}

document.getElementById('tot').value = tott.toString();

}

function emailCheck()

{

alert('trimis!');

return false;

}

</script>

<style type="text/css"> input:disabled { background-color:#ffffff;}</style>

</head>

<body>

<form name="form1" method="post" action="trimite.php" onsubmit="return emailCheck()">

<table width="50%">

<tr><td>Produs</td><td>Pret<br />[RON]</td><td>Cantitate<br />[buc]</td><td>Valoare<br />[RON]</td></tr>

<script type="text/Javascript" language="JavaScript">

for (i=0;i<=produse.length-1;i++)

{

document.write('<tr><td>'+

'<input type="text" name="prod[]" id="prod'+i.toString()+'" value="'+ produse[0]+'" disabled="disabled" >' +

'</td><td>'+

'<input type="text" name="pret[]" id="pret'+i.toString()+'" value="'+ produse[1].toString()+'" disabled="disabled" >' +

'</td><td>'+

'<input type="text" name="cant[]" id="cant'+i.toString()+'" value="0" onchange="caltot();" >' +

'</td><td>'+

'<input type="text" name="val[]" id="val'+i.toString()+'" value="0" disabled="disabled" >' +

'</td></tr>');

}

</script>

<tr><td colspan="3">Total</td>

<td><input type="text" name="tot" id="tot" value="0" disabled="disabled"></td></tr>

</table>

<br /><input type="submit" name="trimite" value="Trimite" />

</form>

</body>

</html>

M-ar interesa cum ar trebui sa arate fisierul trimite.php ca sa imi trimita mie prin email. Sper ca nu par prea cersetor:">

Edited by Iceman.

Share this post


Link to post
Share on other sites


<?php
if(isset($_POST['trimite'])){
if(){} // aici mai faci niste verificari la input-uri (daca vrei)
mail(); // http://php.net/manual/ro/function.mail.php
}
?>

Eventual poti da un print_r($_POST) sa vezi ce field-uri ai...

Bafta!

Share this post


Link to post
Share on other sites

Am incercat... nu prea imi iese. Eu defapt vreau sa fac un magazin online daca se poate numi asa. Un client se uita , adauga o cantitate la produs , vede cat costa in total si da trimite. In momentul cand da Trimite tot ce a modificat el sa m-i se trimita mie pe mail. In fine va trebui sa adaug si o casuta cu adresa lui de email , nr de tel pt. a-l putea contacta. Chiar nu exista nici o solutie?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...