close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Can I display the value associated with a select list item in an Add to cart button

Thread began 1/07/2016 2:37 am by Brendan | Last modified 3/24/2016 1:31 pm by Ray Borduin | 481 views | 4 replies |

Brendan

Can I display the value associated with a select list item in an Add to cart button

The price in my ATC is based on the value associated with a select list in the button. Since the select list items do not include the price, is there any way to display the value of the selected item on the page before the user clicks submit?

To make this a little more tricky (to me) - I have a js calculation as part of this from a premier support session

Attached Files
agency-duescalc.zip
Sign in to reply to this post

Ray BorduinWebAssist

It can be done with Javascript on the page, but since you have the calculation based on the text field as well as the select list it can be kind of complicated.

This is something I could do for you in a premier support ticket.

Sign in to reply to this post

Brendan

Ray, hoping you could help with this. You helped me create the calculation in PM, I have had a couple of transactions fail from what i expect are totals with 3+ decimal places. I'm trying to restrict the result of the formula to 2 decimal places.

<script>
function updatePrice() {
var selVal = document.getElementById('grossSelect').options[document.getElementById('grossSelect').selectedIndex].value;
if (selVal == '0') {
document.getElementById('enterGross').style.display='block';
baseVal = 660;

enteredAmount = document.getElementById('gross').value;
enteredAmount = enteredAmount.replace(/[^\d]/g,"");
enteredAmount = parseInt(enteredAmount);

if (enteredAmount > 500000) {
enteredAmount = enteredAmount - 500000;
baseVal += 35 * (enteredAmount/100000);
}

document.getElementById('calcTot').innerHTML= baseVal;
} else {
document.getElementById('enterGross').style.display='none';
document.getElementById('calcTot').innerHTML=selVal;
}
}
</script>

Sign in to reply to this post

Ray BorduinWebAssist

Try:

<script>
function updatePrice() {
var selVal = document.getElementById('grossSelect').options[document.getElementById('grossSelect').selectedIndex].value;
if (selVal == '0') {
document.getElementById('enterGross').style.display='block';
baseVal = 660;

enteredAmount = document.getElementById('gross').value;
enteredAmount = enteredAmount.replace(/[^\d]/g,"");
enteredAmount = parseInt(enteredAmount);

if (enteredAmount > 500000) {
enteredAmount = enteredAmount - 500000;
baseVal += 35 * (enteredAmount/100000);
}

document.getElementById('calcTot').innerHTML= baseVal.toFixed(2);
} else {
document.getElementById('enterGross').style.display='none';
document.getElementById('calcTot').innerHTML=selVal.toFixed(2);
}
}
</script>

Sign in to reply to this post

Brendan

Thanks Ray, that worked perfectly!!

Sign in to reply to this post

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