hi
i am doing online shop now using php, my product is clothes, Now i am able to let users to order, however i don;t know how should i validate quantity and size field when they select that specific clothes. i just pass it to do_addcart.php but it seems the value never pass through. what should i do now?
how can i let users to put in quantity and size field when they select clothes? i have to validate the quantity and size field before add into cart. also i have to know the vaule of their input.
4 3688 ronnil 134
Recognized Expert New Member
a posibility is to make a hidden field where you store the quantity value. make a div tag where you display that value, and then two image buttons (+ and -) when the user clicks one of these buttons you increase/decrease the number. - <script language="javascript">
-
function changeQuant(quantity)
-
{
-
var hiddenObj = document.getElementById('quantity');
-
var currentQuant = hiddenObj.value;
-
currentQuant = currentQuant + quantity;
-
-
hiddenObj.value = currentQuant;
-
document.getElementById('show_quant').innerHTML = currentQuant;
-
}
-
-
</script>
-
<form>
-
<input type="hidden" name="quantity" id="quantity" value="1" /> <!-- the default value is ofc 1 item -->
-
</form>
-
-
<div id="show_quant"><img onclick="changeQuant(-1)" alt="-" /><img onclick="changeQuant(1)" alt="+" />
ofcourse the hidden field must be attached to whatever form you use to make the order. when submitting it, you will then have a variable by the name of quantity.
This is just one of many solutions :)
Atli 5,058
Recognized Expert Expert
Hi.
Could you show us the code you are using? It helps to see the code your trying to debug :)
My solution to a similar functionality was to add a text field to my form and allow the user to type the quantity they wanted. Then that field would simply be passed to the next page using HTTP_POST and I would validate it there.
If you are not sure how that works you can check out this article , where it is discussed in detail.
yes, i have do the same as what u said, i validate it in the next page, the code is like the following:
in the first page:
in next page: -
$userid = $_SESSION['userid'];
-
-
$date=date("D j-M-Y G:i:s");
-
-
echo "Image ID = ".$_SESSION['id']."<br>";
-
//echo "Image ID = ".$_POST['vin1']."<br>";
-
//echo "Image ID = ".$_POST['vin2']."<br>";
-
//echo "Image ID = ".$_POST['vin3']."<br>";
-
-
$chkbox2 = $_POST['quantity'];
-
$chkbox3 = $_POST['size'];
-
echo $chkbox2;
-
echo $chkbox3;
-
-
if ($chkbox2 == 0 || $chkbox3 == 0){
-
echo "<script>alert('you did not select your quantity and size, we will direct you back')</script>";
-
//header('Refresh: 3; url=index1.php');
-
//break;
-
echo "<meta http-equiv='refresh' content='1;url=index1.php'>";
-
}
-
-
else {
-
foreach ($_POST as $key => $value) {
-
echo "key: ".$key.", value: ".$value."<br>";
-
$sql = "INSERT INTO orders (imageid, userid, time, quantity, size) VALUES ('$key', '$userid', '$date','$chkbox2','$chkbox3')";
-
mysql_query($sql);
-
}
-
-
//header('Refresh: 3; url=cart.php');
-
echo "<meta http-equiv='refresh' content='5;url=http://google.com'>";
-
echo"<BR>";
-
echo "Your order is being processed, you will be directed to your shopping cart soon";
-
}
-
this is code i have done, but it did not post value to the next page, it always 0, and image id is always 16, how should i solve this? thanks for your kind help :)
kovik 1,044
Recognized Expert Top Contributor
You input this into your database very strangely. On the second page, call a print_r($_POST) and tell us what you get.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Michael J. Astrauskas |
last post by:
I'm developing a fairly basic shopping cart. My original implementation
had the user click on a link to add an item to the cart
(addtocart.php?item=123456). I figured it could just increase the
quantity every time the user clicked. However, with caching turned off
the quantity is increased if the user presses back and then forward in
his/her browser. Is there any simple way to avoid this? I noticed that a
lot of online retailers don't...
|
by: Gary Vidal |
last post by:
I have a shopping cart webpage that shows a product and the Quantity they
would like to order:
When you click the link I want to take the quantity that they entered in the
textbox and post that to the next page. But it keeps the original quantity I
added to the viewstate.
Where can i code this to post the correct quantity.
Here is the code-behind I use.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs)...
|
by: HandersonVA |
last post by:
should I set to "0" as a default value on a quantity and a price field
or set to "null"?
if a user enter nothing on the quantity or price field on a web
browser, should I treat it as null or "0"? I am so confused about this
concept. please advise me. thank you.
|
by: Rob Meade |
last post by:
Hi all,
Ok - so I've got the array thing going on, and the session thing going on,
and up until now its all been ok.
I've got my view basket page which is displaying 3 rows (as an example) - I
have an input box on each row enabling the user to update the quantity.
If the enter a zero I need to remove the item from the array....
|
by: Jigar A. Thakor |
last post by:
how to create online shopping website.. ?? any architecture ??
How to design any guidlines ? and what is verisign ?? other secure
protection needed ??
i want to develop in C#,Asp.net,Sql Server...
| |
by: jimmyg123 |
last post by:
Hi,
I'm trying to do something similar. This is my javascript
<script type='text/javascript'>
function totalise(price,total)
{
var qty = window.document.getElementById('qty').value;
var result = total;
result.value = price * qty;
}
|
by: vectorBS |
last post by:
Hi,
I need a suggestion as to which method will be most efficient way of accomplishing this task. I need to build invoice report with Garment Sizes and Quantity. There are seperate records for different sizes with their corresponding quantity in the shipment table. I have to display this information in Invoice Report in a single row with quntities under size lables ( S, M, L, XL, XXL ). Access doesnt allow grouping on multiple fields so i...
|
by: kang jia |
last post by:
hi
i am doing shopping online, i will let user choose their prodcut in the first page and then when they click" order" button, they will be redirected to do_addcart.php. i will insert their orders into "orders" table and retrieve them back and ask user to select their respective quantity and size. i have used Javascript validation:
the code is below:
<script language="JavaScript">
<!--
function validate_form ( )
{
|
by: Just Me |
last post by:
Hi,
OK, Ive been asked to provide a public site with a means of selling some
products, I have never done this before, so im a bit of a newbie really.
What I am looking for is a method of acheiving this within the ASP.NET
develpment arena,
Byt which I dont mean that I want to design a shopping cart system, I want a
low impact , low cost if possible way of being able to set up my products
and sell them using a third party like worldpay...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |