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 ( )
-
{
-
valid = true;
-
alert (document.Lform.quantity.selectedIndex);
-
if ( document.Lform.quantity.selectedIndex == 0 )
-
{
-
alert ( "Please select your quantity!" );
-
Lform.quantity.focus();
-
valid = false;
-
}
-
else if ( document.Lform.size.selectedIndex == 0 )
-
{
-
alert ( "Please select your size!" );
-
Lform.size.focus();
-
valid = false;
-
}
-
return valid;
-
}
-
//-->
-
</script>
However, i don;t know how to correspond respective product with their respective choosen quantity and size.
the following is my current coding, - <?php
-
foreach ($_POST as $key => $value) {
-
echo "key: ".$key.", value: ".$value."<br>";
-
$sql = "INSERT INTO orders (imageid, userid, time) VALUES ('$key', '$userid', '$date')";
-
mysql_query($sql);
-
}
-
-
echo "Please select your size and quantity for purchase:";
-
echo "<table border = '1'>";
-
echo "<tr>";
-
echo "<td>Title";
-
echo "<td>Brand";
-
echo "<td>Price";
-
echo "<td>Size";
-
echo "<td>Quantity";
-
echo "</tr>";
-
$sql2="SELECT imageid FROM orders";
-
$result=mysql_query($sql2);
-
while($row = mysql_fetch_array($result)) {
-
echo "<br>";
-
$sql3="SELECT brand, price, title FROM ladies WHERE id=".$row['imageid'];
-
$ImageResult = mysql_query($sql3);
-
$ImageDetail = mysql_fetch_array($ImageResult);
-
echo "<tr>";
-
echo "<td>".$ImageDetail['title']."";
-
echo "<td>".$ImageDetail['brand']."";
-
echo "<td>".$ImageDetail['price']."";
-
echo"<td>";
-
-
echo"
-
<select id='size' name='size' tabindex='11'>
-
<option value='0'>---
-
<option value='1' >S
-
<option value='2'>M
-
<option value='3'>L
-
<option value='4'>XL
-
</select>
-
</td>";
-
//echo" ";
-
-
-
echo"
-
<td>
-
<select id='NO' name='quantity' tabindex='11'>
-
<option value='0'>---
-
<option value='1' >1
-
<option value='2'>2
-
<option value='3'>3
-
<option value='4'>4
-
<option value='5'>5
-
<option value='6'>6
-
<option value='7'>7
-
<option value='8'>8
-
<option value='9'>9
-
<option value='10'>10
-
</select>
-
</td>";
-
echo "</tr>";
-
}
-
echo "</table>";
-
echo "<input type = 'submit' value = 'order'>";
-
?>
anyone can help me with this, thank you very much. it is bit urgent as the project deadline is near.
Please enclose your coding with [code] tags [Please Find how!]
Jul 7 '07
14 2098 ak1dnar 1,584
Recognized Expert Top Contributor
the default is all 1, but my supervisor don;t think it is practical in real life to let everyone just buy one and they should be able to select the size they wear. that is why i have to do the validation of size and quantity for each item they buy.
i have to insert their size and quantity for the respective item in database, so i have to know which size and quantity is belong to which item.
sure, i will wait for your kind reply. thanks. :)
Just Listen to me again,
Why Customer(s) comes to e-commerce sites. to Buy isn't it.
Do they ever purchasing "0" items. NO.
Its should be greater than 1 always.
Then Size, As I know you are going to display S,M,L,XL with your products.
So can't we set one of them by default. If User don't want that Size say XL is set by default and he needs L so he will do it.
However get in touch with your SUPERvisor :) -
<?php
-
$con = mysql_connect('localhost', 'root', 'dba') or die ("Could not connect to the Database");
-
mysql_select_db('test', $con) or die (mysql_error());
-
$query1 = 'Select p_id from products';
-
$result1 = mysql_query($query1);
-
$query2 = 'Select p_id from products';
-
$result2 = mysql_query($query2);
-
?>
-
<html>
-
<head>
-
<script language="JavaScript" type="text/javascript">
-
function menuChk(){
-
<?php
-
while ($row1 = mysql_fetch_array($result1))
-
{
-
?>
-
var Str<?=$row1['p_id']?> = document.formObj.Qty<?=$row1['p_id']?>.selectedIndex;
-
if (Str<?=$row1['p_id']?> == 0){
-
alert("Please select the Quantity!");
-
document.formObj.Qty<?=$row1['p_id']?>.focus();
-
return false;
-
}
-
<?
-
}
-
?>
-
}
-
</script>
-
</head>
-
<body>
-
<form id="formObj" name="formObj" method="post" action="server.php" onsubmit="return menuChk();">
-
<?php
-
while ($row2 = mysql_fetch_array($result2))
-
{
-
?>
-
<select name="Qty<?=$row2['p_id']?>">
-
<option value="0">0</option>
-
<option value="1">1</option>
-
<option value="2">2</option>
-
</select>
-
<br />
-
<?php
-
}
-
?>
-
<input name="" type="submit" />
-
</form>
-
</body>
-
</html>
-
-
This will print somting like this dynamically. -
<html>
-
<head>
-
<script language="JavaScript" type="text/javascript">
-
function menuChk(){
-
var Str143 = document.formObj.Qty143.selectedIndex;
-
if (Str143 == 0){
-
alert("Please select the Quantity!");
-
document.formObj.Qty143.focus();
-
return false;
-
}
-
var Str144 = document.formObj.Qty144.selectedIndex;
-
if (Str144 == 0){
-
alert("Please select the Quantity!");
-
document.formObj.Qty144.focus();
-
return false;
-
}
-
var Str145 = document.formObj.Qty145.selectedIndex;
-
if (Str145 == 0){
-
alert("Please select the Quantity!");
-
document.formObj.Qty145.focus();
-
return false;
-
}
-
var Str146 = document.formObj.Qty146.selectedIndex;
-
if (Str146 == 0){
-
alert("Please select the Quantity!");
-
document.formObj.Qty146.focus();
-
return false;
-
}
-
var Str147 = document.formObj.Qty147.selectedIndex;
-
if (Str147 == 0){
-
alert("Please select the Quantity!");
-
document.formObj.Qty147.focus();
-
return false;
-
}
-
var Str148 = document.formObj.Qty148.selectedIndex;
-
if (Str148 == 0){
-
alert("Please select the Quantity!");
-
document.formObj.Qty148.focus();
-
return false;
-
}
-
}
-
</script>
-
</head>
-
<body>
-
<form id="formObj" name="formObj" method="post" action="server.php" onsubmit="return menuChk();">
-
<select name="Qty143">
-
<option value="0">0</option>
-
<option value="1">1</option>
-
<option value="2">2</option>
-
</select>
-
<br />
-
<select name="Qty144">
-
<option value="0">0</option>
-
<option value="1">1</option>
-
<option value="2">2</option>
-
</select>
-
<br />
-
<select name="Qty145">
-
<option value="0">0</option>
-
<option value="1">1</option>
-
<option value="2">2</option>
-
</select>
-
<br />
-
<select name="Qty146">
-
<option value="0">0</option>
-
<option value="1">1</option>
-
<option value="2">2</option>
-
</select>
-
<br />
-
<select name="Qty147">
-
<option value="0">0</option>
-
<option value="1">1</option>
-
<option value="2">2</option>
-
</select>
-
<br />
-
<select name="Qty148">
-
<option value="0">0</option>
-
<option value="1">1</option>
-
<option value="2">2</option>
-
</select>
-
<br />
-
<input name="" type="submit" />
-
</form>
-
</body>
-
</html>
-
-
i do think what you said previously is very true , we can just set default value ma, later user want to change, they will change, i will validate my reasons with my supervisor, thanks for your kind help . but if i choose to use the defult one, how should i insert in database.
Remaining section removed from the post,Please read the next thread to find out the reason.
ak1dnar 1,584
Recognized Expert Top Contributor
Sorry I have to delete this post from the thread.
Reason:
Cannot see the post. its empty.
May be its too long.
Please Remove the unwanted static contents from your coding and re-post it.
Thanks!
-Ajaxrand
Sorry I have to delete this post from the thread.
Reason:
Cannot see the post. its empty.
May be its too long.
Please Remove the unwanted static contents from your coding and re-post it.
Thanks!
-Ajaxrand
thanks for your kind help, i just sovled it with my other friends' help, really thanks, you are so nice and kind to help me!
ak1dnar 1,584
Recognized Expert Top Contributor
thanks for your kind help, i just sovled it with my other friends' help, really thanks, you are so nice and kind to help me!
Glad to hear that !Well done!
Come back any time to TSDN. -Ajaxrand Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Sonic |
last post by:
I have an MDE file that is growing exponentially (from 3,900 KB to over
132,000 KB today). I am not saving data in this MDE, although I use a
mix of offline and SQL tables for Read Only querying. I also have many
forms and some reports and queries. Many people use this DB on a daily
basis and there is constantly someone in it, virtually every minute.
The DB tends to crash every couple of weeks. I am wondering if the
size of this...
|
by: Norbert Heidbüchel |
last post by:
Hi all,
I have read a lot of postings and web pages about drag and drop
and treeviews, but could not find an answer to my problem. Sorry, if I
missed something.
I am trying to drag and drop treenodes defined by myself and
don't understand, how to get the nodes data in the dragdrop event.
I'm not very experienced in .NET and for sure there is a simple solution.
I've written a short sample program, based on well known examples,
|
by: Stephen |
last post by:
Could someone please help me with some validation. I have to write code which
checks to see whether a dropdown list is populated with a value or a checkbox
is checked. I want the code to run on the on-click of a button.
My page has 1 dropdown list and two checkboxes. So I either want the user
to choose an item from the dropdownlist OR tick a checkbox(it doesn't matter
if they tick both checkboxes). I can't allow the user to fill in the...
|
by: Moe Sizlak |
last post by:
Hi There,
I am trying to return the value of a listbox control that is included as a
user control, I can return the name of the control but I can't access the
integer value of the selected item, what do I need to do in order to return
the "option value" of the control?
Moe
!--- returned value of the control
|
by: Jimbo |
last post by:
Hello,
I have a user request to build a form in an Access database where the user
can check off specific fields to pull in a query. For example, let's say I
have 10 fields in a table. The user wants to be able to check off anywhere
between 1 and all 10 fields in a form and have it return a select query with
just the fields that were checked off. There are multiple users, so not all
users will be checking off the same fields. Some...
| |
by: tania |
last post by:
i have this table in my database:
CREATE TABLE FILM(
F_ID INT(5) NOT NULL AUTO_INCREMENT,
F_TITLE VARCHAR(40) NOT NULL,
DIRECTOR_FNAME VARCHAR(20) NOT NULL,
DIRECTOR_LNAME VARCHAR(20) NOT NULL,
TYPE VARCHAR(30) NOT NULL,
DURATION TIME ,
YEAR_RELEASE YEAR NOT NULL,
DESCRIPTION TEXT,
|
by: goutam12345 |
last post by:
Hello experts,
Please help....
My checkboxes are not passing respective textboxes values to another page
My checkboxes are moving in a loop
<input type="checkbox" name="chkID" id="chkID" value="<?=$rowSubjectsx?>">
My text boxes are also moving in a loop
<input type="text" name="quantity" id="quan" size="3"/>
I want to show respective check boxes subjects and quantity to another page
Please help.......
|
by: =?Utf-8?B?UGF1bA==?= |
last post by:
Hallo,
I have a radiobuttonlist control that is added on a custom Web User Control.
This control has a property that exposes the SelectedIndex property of the
embedded radiobuttonlist.
When running this in IE, behaviour is as I would expect it. If I select an
item and do a postback, the page remembers my selection when reloading, and
the SelectedIndex property of my control returns the correct value.
|
by: kurtzky |
last post by:
i created a form that should function as follows:
i will enter a number in a textbox..then it should query from the database all the records which has that number..these records will have a different item no in it..then, these records will be saved in a temporary datatable (which i made in a separate class, the name is WBASKET)...The item nos of these records will be displayed in a combobox, say item1, item2, etc..
then,i have a datagrid...
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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...
| |