close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Adding <select> Items to Cart

Thread began 1/29/2014 9:44 am by Mike Perry | Last modified 1/30/2014 10:07 am by Jason Byrnes | 1871 views | 11 replies |

Mike Perry

Adding <select> Items to Cart

I have An Item Select Page where Training Packages can be purchased for a specified player.

The Player is selected from a recordset filtered by the User's ID, and chosen by a <select> and Dynamic <option> form> (Code follows)

*****************************************************************************************
<form id="playerSelect" name="playerSelect" style="margin:10px 100px;">
<fieldset title="">
<select name="Player" id="Player">
<option value=0>Select a Player to Sign Up</option>
<?php
// RepeatSelectionCounter_1 Begin Loop
$RepeatSelectionCounter_1_IterationsRemaining = $RepeatSelectionCounter_1_Iterations;
while($RepeatSelectionCounter_1_IterationsRemaining--){
if($RepeatSelectionCounterBasedLooping_1 || $row_myPlayers){
?> <option value="<?php echo $row_myPlayers['id']; ?>"><?php echo $row_myPlayers['playerFirstName']." ".$row_myPlayers['playerLastName']; ?></option>
<?php
} // RepeatSelectionCounter_1 Begin Alternate Content
else{
?>
<?php } // RepeatSelectionCounter_1 End Alternate Content
if(!$RepeatSelectionCounterBasedLooping_1 && $RepeatSelectionCounter_1_IterationsRemaining != 0){
if(!$row_myPlayers && $RepeatSelectionCounter_1_Iterations == -1){$RepeatSelectionCounter_1_IterationsRemaining = 0;}
$row_myPlayers = mysql_fetch_assoc($myPlayers);
}
$RepeatSelectionCounter_1++;
} // RepeatSelectionCounter_1 End Loop
?>
</select><br><br><br>

</fieldset>
</form>

***********************************************************************'

Then a second Form is revealed, with a <select> and Dynamic <option> providing a list of available packages

************************************************************************

<form id="TrainSelect" name="TrainSelect" style="margin:10px 100px;">
<fieldset>
<select name="TO" id-"TO">
<option>Select a Training Option</option>
<?php
// RepeatSelectionCounter_2 Begin Loop
$RepeatSelectionCounter_2_IterationsRemaining = $RepeatSelectionCounter_2_Iterations;
while($RepeatSelectionCounter_2_IterationsRemaining--){
if($RepeatSelectionCounterBasedLooping_2 || $row_trainingOptions){
?>
<option value="<?php echo $row_trainingOptions['ProductID']; ?>" alt="<?php echo $row_trainingOptions['ProductLongDesc']; ?>" title="<?php echo $row_trainingOptions['ProductLongDesc']; ?>"><?php echo $row_trainingOptions['ProductShortDesc']; ?></option>
<?php
} // RepeatSelectionCounter_2 Begin Alternate Content
else{
?>
<?php } // RepeatSelectionCounter_2 End Alternate Content
if(!$RepeatSelectionCounterBasedLooping_2 && $RepeatSelectionCounter_2_IterationsRemaining != 0){
if(!$row_trainingOptions && $RepeatSelectionCounter_2_Iterations == -1){$RepeatSelectionCounter_2_IterationsRemaining = 0;}
$row_trainingOptions = mysql_fetch_assoc($trainingOptions);
}
$RepeatSelectionCounter_2++;
} // RepeatSelectionCounter_2 End Loop
?>
</select>
</fieldset>
</form>

***************************************************************

What is the best way to bind the information from these two drop-downs to the PlayerID and ItemID in the cart Object??

Thanks,

Mike

Sign in to reply to this post

Jason ByrnesWebAssist

add hidden elements to the second form to capture the values posted from the first

use the add to cart server behavior.

on the server behaviors panel, click the plus button and select eCart -> Add to Cart -> add to cart.

in the bindings section, bind the cart column to the corresponding form elements from the second form. also, set the trigger to the submit button for the second form.

Sign in to reply to this post

Mike Perry

I'm probably not adding the value from the first form correctly. The page reloads and the "PlayID" variable in the address bar is empty. The value for the Item is passed correctly.

Here's how I'm adding the value to the hidden <input>:

<input type="hidden" value="<?php echo((isset($_POST["Player"]))?$_POST["Player"]:"") ?>" name="PlayID">

Chosen by dragging the Binding for the First form element to the page.

Obviously not right. . .

Code for the Add to Cart Behavior:

*****************************************
<?php
// WA eCart Trigger AddToCart
if (isset($_POST["ATC_Submit"])){
$cart = $sherwin1;
$ATC_itemID = "1";
$ATC_AddIfIn = 0;
$ATC_RedirectAfter = "mycart.php";
$ATC_RedirectIfIn = "";
$ATC_itemName = "";// column binding
$ATC_itemDescription = "";// column binding
$ATC_itemThumbnail = "";// column binding
$ATC_itemWeight = floatval("0");// column binding
$ATC_itemQuantity = floatval("".$_POST["sherwin1_1_Quantity_Add"] ."");// column binding
$ATC_itemPrice = floatval("0");// column binding
$ATC_itemPlayerID = floatval("".((isset($_POST["PlayID"]))?$_POST["PlayID"]:"") ."");// column binding
$ATC_itemItemID = floatval("".((isset($_POST["TO"]))?$_POST["TO"]:"") ."");// column binding
$ATC_itemQuantity = floatval($ATC_itemQuantity);
if (is_numeric($ATC_itemQuantity) && $ATC_itemQuantity != 0) {
$cart->AddToCart($ATC_AddIfIn, $ATC_RedirectIfIn, $ATC_itemID, $ATC_itemName, $ATC_itemDescription, $ATC_itemThumbnail, $ATC_itemWeight, $ATC_itemQuantity, $ATC_itemPrice, $ATC_itemPlayerID, $ATC_itemItemID);
if ($ATC_RedirectAfter != "" && $cart->redirStr == "") {
$cart->redirStr = $ATC_RedirectAfter;
}
if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != "") {
$_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
}
else {
$_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF'];
}
}
}
?>
***************************************************************

Thanks,

Sign in to reply to this post

Jason ByrnesWebAssist

looks correct. I'll need to troubleshoot directly, see the private message section.

Sign in to reply to this post

Mike Perry

Here ya go

Sign in to reply to this post

Jason ByrnesWebAssist

i see, the first form uses the GET method, so:
<input type="hidden" value="<?php echo((isset($_POST["Player"]))?$_POST["Player"]:"") ?>" name="PlayID">

should be:
<input type="hidden" value="<?php echo((isset($_GET["Player"]))?$_GET["Player"]:"") ?>" name="PlayID">


on the second form, change the method to post, the add to cart button will need to have the form sent using the post method instead of the get method.

Sign in to reply to this post

Mike Perry

Okay -- made the following changes:

<input type="hidden" value="<?php echo((isset($_GET["Player"]))?$_GET["Player"]:"") ?>" name="PlayID"> (hidden element)

<form class="secCopy" id="TrainSelect" name="TrainSelect" style="margin:10px 100px;" method="post"> (2nd form)

<input type="submit" name="ATC_Submit" id="Submit" value="Submit" formmethod="post"> (Submit Button)

Now the page reloads with just the filename in the address bar -- no other arguments. . .

Thanks. . .

Sign in to reply to this post

Jason ByrnesWebAssist

right, because it is using the post method, you should set the eCart add to cart behavior to redirect to a cart display page.

Sign in to reply to this post

Mike Perry

I have redirect set to mycart.php.

Sign in to reply to this post

Jason ByrnesWebAssist

Please provide a Skype username or a US phone number and a good time to contact you when you will be in front of your computer and we will have an engineer contact you to resolve this issue over the phone.

We are available Monday - Friday from 9am - 4pm EST (except major U.S. holidays).

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...