close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

List values in relation to price variants . . .

Thread began 7/17/2009 6:17 pm by wetware | Last modified 7/20/2009 7:01 am by wetware | 7037 views | 14 replies

CraigRBeta Tester

try this...

You need to store the label string value as a hidden field in the add to cart form, setting a default value, (this value is only updated onchange in this example).

eg <input type="hidden" name="label" value="Small" >

In this example, the list/menu is called listsize and calls a js function called 'getlabelstring' as follows....

<select name="listsize" onchange="getlabelstring()">
<option value="10">Small</option>
<option value="20">Medium</option>
<option value="30">Large</option>
</select>

the javascript function to retrieve the list label should go in the head section of your page.

the function has the general structure as below, just substitute the formname, listbox name and hidden fields accordingly

document.formname.label.value=document.formname.listbox.options[document.formname.listbox.selectedIndex].text

in this example, my add to cart form is called gallerybasket_1_ATC_<?php echo $row_rsdetail["ID"]; ?> the listbox is called listsize, the label is called label, so the function is like this...

<script type="text/javascript">
/* <![CDATA[ */
function getlabelstring(){

document.gallerybasket_1_ATC_<?php echo $row_rsdetail["ID"]; ?>.label.value = document.gallerybasket_1_ATC_<?php echo $row_rsdetail["ID"]; ?>.listsize.options[document.gallerybasket_1_ATC_<?php echo $row_rsdetail["ID"]; ?>.listsize.selectedIndex].text;

}
/* ]]> */
</script>


now set the size in the add to cart behavior... $ATC_itemSize = "".$_POST["label"] ."";// column binding#



if you wish to display the price as well as the size in the list label, eg

<select name="listsize" onchange="getlabelstring()">
<option value="10">Small ($10.00)</option>
<option value="20">Medium ($20.00)</option>
<option value="30">Large ($30.00)</option>
</select>

you would need to do some string manipulation to extract the appropriate substring from the label.

eg to extract all characters until the space

<script type="text/javascript">
/* <![CDATA[ */
function getlabelstring(){

var firstbit = document.gallerybasket_1_ATC_<?php echo $row_rsdetail["ID"]; ?>.listsize.options[document.gallerybasket_1_ATC_<?php echo $row_rsdetail["ID"]; ?>.listsize.selectedIndex].text;

firstbit = firstbit.split(" ");

document.gallerybasket_1_ATC_<?php echo $row_rsdetail["ID"]; ?>.label.value = firstbit[0];

}
/* ]]> */
</script>

(I haven't tested this if js is disabled, the price will still calculate ok, but I presume that the size info from the label will not.)

:)

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...