Thread: I need Help with Dropdown list
Results 1 to 12 of 12
Related
-
Dropdown menu hides behind dropdown box Forum: Javascript Forum
Replies: 0 -
Help me about Dropdown ListBox Forum: HTML Forum
Replies: 1 -
Dropdown menues Forum: HTML Forum
Replies: 1 -
Dropdown Overlap Forum: HTML Forum
Replies: 7
-
08-06-2003, 03:06 PM #1
I need Help with Dropdown list
I have a Dropdown list with Select with 1, 2, 3, 4, after select on of them it bust to refresh the page to what you select but it don't do it. Can you all see what the error is for me? I look over and over i don't see any error or it not the right on i need.
Here All The Code On The Page
PHP Code:<script language="php">
// find out what you want to do with the cart with action variable and act accordinly
global $action, $cartId, $itemId, $qty, $itemoptions, $shortdesc, $longdesc, $prodprice, $updater;
if($action == "add_item") {
AddItem();
ShowCart();
}
if($action == "update_item") {
UpdateItem();
ShowCart();
}
if($action == "update_option") {
UpdateItemOption();
ShowCart();
}
if($action == "remove_item") {
RemoveItem();
ShowCart();
}
if($action == "empty_cart") {
EmptyCart();
ShowCart();
}
if(!$action) {
ShowCart();
}
function AddItem()
{
global $eurocash, $cartId, $itemId, $qty, $itemoptions, $shortdesc, $longdesc, $prodprice, $prodtotalcost, $catId;
include "adminshop/config/shop_db.php";
$db = mysql_connect($host, $dbuser, $dbpass);
mysql_select_db($dbase,$db);
$result = mysql_query("select * from cart where cartId = '$cartId' and itemId = '$itemId' and itemoptions = '$itemoptions'");
$row = mysql_fetch_row($result);
$numRows = $row[0];
if($numRows == 0)
{
// This item doesn't exist in the users cart,
// we will add it with an insert query
$query = "INSERT INTO cart VALUES ('$cartId', '$itemId', '$qty', '$itemoptions', '$shortdesc', '$longdesc', '$prodprice', '$catId')";
$result = MYSQL_QUERY($query);
}
else
{
// This item already exists lets update it.
$query = "UPDATE cart set qty = qty + '$qty' where cartId = '$cartId' and itemId = '$itemId' and itemoptions = '$itemoptions'";
$result = MYSQL_QUERY($query);
}
}
function UpdateItem()
{
global $cartId, $itemId, $qty, $itemoptions, $shortdesc, $longdesc, $prodprice, $prodtotalcost;
// Updates the quantity of an item in the users cart.
// If the qutnaity is zero, then RemoveItem will be
// called instead
include "adminshop/config/shop_db.php";
$db = mysql_connect($host, $dbuser, $dbpass);
mysql_select_db($dbase,$db);
mysql_query("update cart set qty = '$qty' where cartId = '$cartId' and itemId = '$itemId' and itemoptions = '$itemoptions'");
}
function UpdateItemOption()
{
global $cartId, $itemId, $qty, $itemoptions, $shortdesc, $longdesc, $prodprice, $prodtotalcost, $prevoption;
include "adminshop/config/shop_db.php";
$db = mysql_connect($host, $dbuser, $dbpass);
mysql_select_db($dbase,$db);
$result = mysql_query("select * from cart where cartId = '$cartId' and itemId = '$itemId' and itemoptions = '$itemoptions'");
$row = mysql_fetch_row($result);
$numRows = $row[0];
if($numRows == 0)
{
// This items size doesn't exist in the users cart,
// we will update old with an insert query
mysql_query("update cart set itemoptions = '$itemoptions' where cartId = '$cartId' and itemId = '$itemId' and itemoptions = '$prevoption'");
}
else
{
mysql_query("update cart set qty = qty + '$qty' where cartId = '$cartId' and itemId = '$itemId' and itemoptions = '$itemoptions'");
mysql_query("delete from cart where cartId = '$cartId' and itemId = '$itemId' and itemoptions = '$prevoption'");
}
}
function RemoveItem()
{
global $cartId, $itemId, $qty, $itemoptions, $shortdesc, $longdesc, $prodprice, $prodtotalcost;
include "adminshop/config/shop_db.php";
$db = mysql_connect($host, $dbuser, $dbpass);
mysql_select_db($dbase,$db);
mysql_query("delete from cart where cartId like '$cartId' and itemId like '$itemId' and itemoptions like '$itemoptions'");
}
function EmptyCart()
{
global $cartId, $itemId, $qty, $itemoptions, $shortdesc, $longdesc, $prodprice, $prodtotalcost;
include "adminshop/config/shop_db.php";
$db = mysql_connect($host, $dbuser, $dbpass);
mysql_select_db($dbase,$db);
mysql_query("delete from cart where cartId like '$cartId'");
}
function ShowCart()
{
global $shipTotal, $grandTotal, $usdollarcost, $usdollar, $usdollartotalcost, $imageProdFolder, $cartId, $itemId, $qty, $itemoptions, $shortdesc, $longdesc, $prodprice, $prodtotalcost;
$grandTotal = 0;
$totalCost = 0;
$itemcount = 0;
include "adminshop/config/shop_db.php";
$db = mysql_connect($host, $dbuser, $dbpass);
mysql_select_db($dbase,$db);
$result = mysql_query("select * from cart where cartId = '$cartId'");
while($row = mysql_fetch_array($result))
{
// Increment the total cost of all items
$prodprice = $row["prodprice"];
$prodtotalcost = number_format($row["qty"] * $row["prodprice"], 2, ".", ",");
$totalCost += $row["qty"] * $row["prodprice"];
$itemname = $row["itemId"];
$totalOption = $row["itemoptions"];
$optionitem = $row["itemId"];
$optionitemqty = $row["qty"];
$usdollarcost = $prodprice * $usdollar;
$usdollarcost = number_format($usdollarcost, 2, ".", ",");
</script>
<tr>
<td align="center">
<script language="php">
// this creates the quantity select box for the item.
printf("<select name=\"$itemname\" onChange=\"UpdateQty(this, '$totalOption')\">");
for($i = 1; $i <= 5; $i++)
{
echo "<option ";
if($row["qty"] == $i)
{
echo " SELECTED>" . $i . "</option>";
} else {
echo ">" . $i . "</option>";
}
}
</script>
-
08-06-2003, 03:18 PM #2
Hiya,
Would you mind explaining a little more what its supposed to do, and what its not doing?
We cannot try your code out (needs database) so need a little more info please. eg, does it populate the dropdowns okay, is it just the javascript changer thats not working etc etcIf one of our members helps you, please click theicon to add to their reputation!
No support via email or private message - use the forums!
Before you ask, have you Searched?
-
08-06-2003, 03:29 PM #3
I need Help with Dropdown list
Ok it showing up It not refresh the page it got on it 1, 2, 3,4,5, select one of them it bust to readload the page. It use for a qty select dropdown list.
-
08-06-2003, 03:35 PM #4
Okay,
for it to refresh, reload or submit the page, it has to either be done via JavaScript, or be a form. I cannot see an </select> tag, an </form> tag or a <submit> tag.
if using JavaScript, then it must use the JavaScript function UpdateQty() mentioned in the select. Where is this? I cannot see it in your code.If one of our members helps you, please click theicon to add to their reputation!
No support via email or private message - use the forums!
Before you ask, have you Searched?
-
08-06-2003, 03:45 PM #5
I need Help with Dropdown list
PHP Code:<script language="php">
// this creates the quantity select box for the item.
printf("<select name=\"$itemname\" onChange=\"UpdateQty(this, '$totalOption')\">");
for($i = 1; $i <= 5; $i++)
{
echo "<option ";
if($row["qty"] == $i)
{
echo " SELECTED>" . $i . "</option>";
} else {
echo ">" . $i . "</option>";
}
}
</script>
-
08-06-2003, 04:00 PM #6
Nope. Thats the php script that echos out the select box. However, it does not have an </select> at all. Also, you see where it says onChange? This is where a JavaScript function is called. the JavaScript (Not php!) function is called UpdateQty. Where is the code for this? if it does not exist, then that is why your page does not reload.
have a look at the dropdownmaker tool, it shows you how these are supposed to work.If one of our members helps you, please click theicon to add to their reputation!
No support via email or private message - use the forums!
Before you ask, have you Searched?
-
08-06-2003, 04:30 PM #7
I need Help with Dropdown list
How would i go about making one for that? Here there Script for a pull down menu
PHP Code:// If your ProductOptions is justChoc, Vanilla is not available.
if ($optioname == "justChoc"){
echo "Flavor: <select size=\"1\" name=\"itemoptions$itemcount\" $useupdater><option value=\"justChoc\" SELECTED>Creamy Chocolate</option></select>";
}
Ok i think this what pull down menu call for i'm not shore.
PHP Code:// this section is used on cartview.php.
// You must create a select option for each available combination.
// If your ProductOptions is chocVan, give them a choice of both.
if ($optioname == "chocVan"){
echo "Flavor: <select size=\"1\" name=\"itemoptions$itemcount\" $useupdater><option value=\"justChoc\" SELECTED>Creamy Chocolate</option><option value=\"justVan\">VANILLA Smoothie</option></select>";
}
// If your ProductOptions is justChoc, Vanilla is not available.
if ($optioname == "justChoc"){
echo "Flavor: <select size=\"1\" name=\"itemoptions$itemcount\" $useupdater><option value=\"justChoc\" SELECTED>Creamy Chocolate</option></select>";
}
// If your ProductOptions is justVan, Chocolate is not available.
if ($optioname == "justVan"){
echo "Flavor: <select size=\"1\" name=\"itemoptions$itemcount\" $useupdater><option value=\"justVan\">VANILLA Smoothie</option></select>";
}
} else {
Last edited by knightjt02; 08-06-2003 at 04:44 PM.
-
08-06-2003, 04:58 PM #8
Did you actually write this script to begin with?
If one of our members helps you, please click theicon to add to their reputation!
No support via email or private message - use the forums!
Before you ask, have you Searched?
-
08-06-2003, 05:27 PM #9
I need Help with Dropdown list
I have one more Question to ask how do you call for a text.txt file in a pull down menu?
-
08-06-2003, 05:32 PM #10
I am not sure what you mean by 'call a text file' into a pull down menu?
If one of our members helps you, please click theicon to add to their reputation!
No support via email or private message - use the forums!
Before you ask, have you Searched?
-
08-06-2003, 05:46 PM #11
I need Help with Dropdown list
will go to this page right and see the pull down menu http://www.knightmerchandise.com/ttt/checkout.php
it call by a text file.
I likt to have the setup to work on my shipping cart page but i don't know how to call it.
-
08-06-2003, 06:04 PM #12
Oh, i see. The data is stored in a file.
You can read the file into an array using the php function file ( www.php.net/file/ )
You can manipulate that array using the various array functions ( www.php.net/array/ )
You can then call a loop that outputs each array item as a select option ( www.php.net/while/ , or even better www.php.net/for_each/ )
All these references point to the php manual. Its the best manual I have ever seen, and you can download if you want.
In case you didnt know, you can search/lookup any reference for a php command by adding it to the php.net address like I have above. If the function exists, it takes you direct to the manual page. If the function does not exist, it searches the manual/site for matches. very usefulIf one of our members helps you, please click theicon to add to their reputation!
No support via email or private message - use the forums!
Before you ask, have you Searched?