Aide pour réaliser un bon de commande en php et html
flexi2202
Posted messages
3640
Registration date
Status
Member
Last intervention
-
flexi2202 Posted messages 3640 Registration date Status Member Last intervention -
flexi2202 Posted messages 3640 Registration date Status Member Last intervention -
Hello everyone
Having limited knowledge in PHP and HTML, I am trying to create an order form
Here is an example of what I am working on, but this is just a draft
For now, I am stuck on the shipping costs. I have added a dropdown list
with the choice of delivery method, but I would like the price to display next to the choice and be added to the total price of the order
Thank you for the help
Having limited knowledge in PHP and HTML, I am trying to create an order form
Here is an example of what I am working on, but this is just a draft
For now, I am stuck on the shipping costs. I have added a dropdown list
with the choice of delivery method, but I would like the price to display next to the choice and be added to the total price of the order
Thank you for the help
<html> <head> <title>A simple form example</title> <script type="text/javascript"> var port = 5.95; var tva = 0.076; function calculerPrix (champQte) { var champPrix = champQte.form.elements[champQte.name + "prix"]; var champPrixUnite = champQte.form.elements[champQte.name + "unite"]; var prixUnite = parseFloat(champPrixUnite.value); var qte = champQte.value; if (qte == "") qte = 0; else if (isNaN(qte)) qte = 0; else qte = Math.floor(qte); if (qte < 0) qte = 0; var prix = prixUnite * qte; champPrix.value = formatPrix(prix); calculerTotal(champQte.form); } function calculerTotal (form) { var champTva = form.elements['tva']; var champPort = form.elements['port']; var champTotal = form.elements['total']; champPort.value = formatPrix(port); var total = 0; for (var i in form.elements) { if ( //form.elements[i].name i.toLowerCase().indexOf("prix") != -1) total += parseFloat(form.elements[i].value); } total += port; var tvaCalc = tva * total; tvaCalc = Math.round(tvaCalc*100)/100.0; champTva.value = formatPrix(tvaCalc); total += tvaCalc; champTotal.value = formatPrix(total); } function formatPrix (n) { n = Math.round(n*100)/100.0; var str = ""+n+""; var i = str.indexOf("."); if (i == -1) str += ".00"; else if (i == str.length-2) str += "0"; return str; } // --> </script> </head> <body> <H <HR> <form method="post" action="formulaire-simple.cgi"> <H2>Order Form </H2> <form name="f1"> <p>Order our items!<br /> </p> <p> <table> <tr> <td ></td> <td>Item</td> <td>Quantity</td> <td>Price per unit</td> <td>Price based on quantity</td> </tr> <tr> <td ></td> <td> <select name="color"> <option selected>White <option>Yellow <option>Orange <option>Red <option>Green <option>Blue <option>Purple <option>Black </select> </td> <td> <input type="text" size="3" name="c1" onchange="calculerPrix(this);" /> </td> <td> <input type="text"size="6" name="c1unite" value="29.90" /> </td> <td> <input type="text" name="c1prix" size="6" value="0.00" /> </td> </tr> <tr> <td ></td> <td> <select name="color"> <option selected>White <option>Yellow <option>Orange <option>Red <option>Green <option>Blue <option>Purple <option>Black </select></td> <td> <input type="text" size="3" name="c2" onchange="calculerPrix(this);" /> </td> <td> <input type="text" size="6" name="c2unite" value="89.90" /> </td> <td> <input type="text" name="c2prix" size="6" value="0.00" /> </td> </tr> <tr> <td ></td> <td> <select name="color"> <option selected>White <option>Yellow <option>Orange <option>Red <option>Green <option>Blue <option>Purple <option>Black </select></td> <td> <input type="text" size="3" name="c3" onchange="calculerPrix(this);" /> </td> <td> <input type="text" size="6" name="c3unite" value="9.95" /></td><td> <input type="text" name="c3prix" size="6" value="0.00" /> </td> </tr> <tr> <td height="40px"></td> </tr> <tr> <td ">Delivery method choice </td> <td> <select name="color"> <option selected>Worldwide relay Belgium <option>Postal shipping Belgium <option>Worldwide relay France <option>Postal shipping France <option>Worldwide relay other countries <option>Postal shipping other countries </select></td> <td> </td><td> </td> <td> <input type="text" name="port" value="6.95" size="6" /> </td> </tr> <tr> <td>TOTAL</td> <td ></td> <td> </td> <td> </td> <td> <input type="text" name="total"value="0.00" size="6" /> </td> </tr> </table> </p> </form> What is your first name? <input name="prenom"> <P> What is your street? <input name="rue"> <P> <P> Your number? <input name="numero"> <P> <P> Your locality? <input name="localite"> <P> <P> Your city? <input name="ville"> <P> Do you like computers? <input type="radio" name="choix" value="yes" checked> Yes or <input type="radio" name="choix" value="no"> No <P> Please briefly explain below the choice you just made: <input name="message" size=60,5> <P> Click on <input type="submit" value="Validate"> to submit your request, or <input type="reset" value="Cancel"> </form> </body> </html>
12 answers
Hello,
You are talking about PHP ...... but I don't see a single line of it!
I also specify that your HTML code is incorrect
The name of your select is not correct.... you already have a color above...
Your option tags are not closed
You did not put a value attribute in your options.
Start by correcting your HTML
Then come back and explain if you are indeed in PHP .... (but given your question.. it's more like JavaScript ...)
Also explain how you link your choice of delivery method .. and the fees...(where is this data stored?? an array? in DB? in a config file??)
--
Best regards,
Jordane
You are talking about PHP ...... but I don't see a single line of it!
I also specify that your HTML code is incorrect
<select name="color"> <option selected>world relay belgium </option> <option>postal shipping belgium </option> <option>world relay france </option> <option>postal shipping france </option> <option>world relay other countries </option> <option>postal shipping other countries </option> </select>
The name of your select is not correct.... you already have a color above...
Your option tags are not closed
You did not put a value attribute in your options.
Start by correcting your HTML
Then come back and explain if you are indeed in PHP .... (but given your question.. it's more like JavaScript ...)
Also explain how you link your choice of delivery method .. and the fees...(where is this data stored?? an array? in DB? in a config file??)
--
Best regards,
Jordane
Good evening everyone
thank you for your help
here I have managed to find a base in JavaScript for an order form that I still need to modify as follows
when selecting a session, a reference should be indicated automatically as well as the price
then add shipping costs depending on the delivery method
finally, add everything up
but now I would like this form to be sent to me in PHP and that the client receives a confirmation message
thank you for your help
here I have managed to find a base in JavaScript for an order form that I still need to modify as follows
when selecting a session, a reference should be indicated automatically as well as the price
then add shipping costs depending on the delivery method
finally, add everything up
but now I would like this form to be sent to me in PHP and that the client receives a confirmation message
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Page Title</title>
<link rel="stylesheet" href="style.css">
<script type="text/javascript">
function addRow(tableID) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var colCount = table.rows[0].cells.length;
for(var i=0; i<colCount; i++) {
var newcell = row.insertCell(i);
newcell.innerHTML = table.rows[1].cells[i].innerHTML;
//alert(newcell.childNodes);
switch(newcell.childNodes[0].type) {
case "text":
newcell.childNodes[0].value = "";
break;
case "checkbox":
newcell.childNodes[0].checked = false;
break;
case "select-one":
newcell.childNodes[0].selectedIndex = 0;
break;
}
}
}
function deleteRow(tableID) {
try {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
for(var i=0; i<rowCount; i++) {
var row = table.rows[i];
var chkbox = row.cells[0].childNodes[0];
if(null != chkbox && true == chkbox.checked) {
if(rowCount <= 2) {
addRow(tableID);
// alert("Attention la 1ère ligne n'est pas supprimable. La quantité est initialisée à 0");
// break;
}
table.deleteRow(i);
rowCount--;
i--;
}
}
}catch(e) {
alert(e);
}
}
function testValue(selection) {
if (selection.value == "Dawn") {
// do something
}
else if (selection.value == "Noon") {
// do something
}
else if (selection.value == "Dusk") {
// do something
}
else {
// do something
}
}
</script>
</head>
<body>
Fill in the form to validate your order
<form action="inscription.php" method="post">
<fieldset class="coordonnees">
<legend>Your Details</legend>
<label for="nom">Name</label>
<input id="nom" name="nom" pattern="[a-Z]{*}" type="text" si>
<br>
<label for="prenom">First Name</label>
<input id="prenom" name="prenom" type="text">
<br>
<label for="mail">Email</label>
<input id="mail" name="mail" type="text">
<br>
<label for="mail_conf">Confirm Email</label>
<input id="mail_conf" name="Confirm Email" type="text">
<br>
<legend>Address</legend>
<label>Street</label>
<input id="rue" name="rue" type="text">
<br>
<label>Postal Code</label>
<input id="code-postal" name="code-postal" type="text"><br>
<label>City</label>
<input id="ville" name="ville" type="text"><br>
</fieldset>
<fieldset class="Your order">
<legend>Your Order</legend>
<title> Order Table </title>
<table border="1" id="TableID" style="width: 350pxpx;">
<tr>
<th bgcolor="grey" td="" width="15"></th><th bgcolor="grey" td="" width="90">Session</th><th bgcolor="grey" td="" width="90">Reference</th><th bgcolor="grey" td="" width="75">Format</th><th bgcolor="grey" td="" width="45">Print</th><th bgcolor="grey" td="" width="45">Quantity</th><th bgcolor="grey" td="" width="45">Price</th></tr>
<tr>
<td><input name="chk" size="15" type="checkbox" /></td>
<td>
<select name="Session" style="width: 90;">
<option selected="" value="Choice">Select your session</option>
<option selected="" value="Session 1">Session 1</option>
<option value="Session 2">Session 2Session 2</option>
</select>
<td><input name="Ref" size="25" type="text" /></td>
<td>
<select name="Format" style="width: 90;">
<option value="10*15">10*15</option>
<option value="11*15">11*15</option>
<option value="20*30">20*30</option>
</select>
</td>
<td>
<select name="Print" style="width: 10;">
<option value="Mat">Mat</option>
<option value="Glossy">Glossy</option>
<option value="Satin">Satin</option>
</select>
</td>
<td>
<select name="Quantity" style="width: 20;">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</td>
<td><input name="Price" readonly="" type="text" /></td>
</td></tr>
</table>
</fieldset>
<input onclick="addRow('TableID')" type="button" value="Add" />
<input onclick="deleteRow('TableID')" type="button" value="Delete" />
</body>
</html>
Hello
Thank you for the help
So to answer your questions
I am a fisherman and it occasionally happens that I sell small equipment but not enough to get a paid accommodation
So I try to find a free host for sending the order form in PHP or in another way
For now, I found 000webhost.com
So the page is hosted by this provider
When you talk to me about making a sublime of my form (I see more or less what it means ...)
It is currently a file in JavaScript and HTML in which I would like to add PHP for sending to my email address
The goal of this order form
Would be for the customer to enter their details
Choose the equipment
And delivery method
So that everything is calculated
Then that everything is sent to them and that I receive a copy
I tried to find templates that I could modify online but they are very rare
Thank you for the help
So to answer your questions
I am a fisherman and it occasionally happens that I sell small equipment but not enough to get a paid accommodation
So I try to find a free host for sending the order form in PHP or in another way
For now, I found 000webhost.com
So the page is hosted by this provider
When you talk to me about making a sublime of my form (I see more or less what it means ...)
It is currently a file in JavaScript and HTML in which I would like to add PHP for sending to my email address
The goal of this order form
Would be for the customer to enter their details
Choose the equipment
And delivery method
So that everything is calculated
Then that everything is sent to them and that I receive a copy
I tried to find templates that I could modify online but they are very rare
Good evening
now that it works
I am trying to transform it into an order form
I have therefore added a piece of code in the html and added a JS file
but already the first problems appear with the html code
for help with html can I ask here or should I post in the html section
now that it works
I am trying to transform it into an order form
I have therefore added a piece of code in the html and added a JS file
but already the first problems appear with the html code
for help with html can I ask here or should I post in the html section
Thank you for the response
but I will rather put it on hold because once the HTML is in order, everything will need to be sent.
but I will rather put it on hold because once the HTML is in order, everything will need to be sent.
Sorry, I made a mistake while selecting the topic
Actually, I'm stuck on several things and for several days I've been scouring the internet looking for an example of an order form that I could adapt to my convenience
All I have for now is a form where I'm trying to integrate a piece of HTML code for the order form
For now, I'm stuck with an issue in HTML
https://forums.commentcamarche.net/forum/affich-36862321-soucis-avec-un-morceau-de-code-en-html?jrRbgNTBHfJS1Grd29tNS-82sTuA7XL4cLjsezgN0rU#newanswer
Actually, I'm stuck on several things and for several days I've been scouring the internet looking for an example of an order form that I could adapt to my convenience
All I have for now is a form where I'm trying to integrate a piece of HTML code for the order form
For now, I'm stuck with an issue in HTML
https://forums.commentcamarche.net/forum/affich-36862321-soucis-avec-un-morceau-de-code-en-html?jrRbgNTBHfJS1Grd29tNS-82sTuA7XL4cLjsezgN0rU#newanswer
thank you for the help actually I'm trying to get inspired by this model I just found
https://jsfiddle.net/gp1f2x5n/1/
but when I download the HTML, CSS, and JavaScript codes
the add button in the form doesn't work
and then I would like the order form to be sent to me in PHP once it is filled out
for the one I just posted I tried to combine two codes but apparently I messed up
so I would like to know if we could try to get this new model I found to work
thank you for the help