Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6617329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:41:28+00:00 2026-05-25T20:41:28+00:00

I have tried Googling this but it only ever comes up with the jQuery

  • 0

I have tried Googling this but it only ever comes up with the jQuery noconflict option.

I would use this but my site is very jQuery heavy and it will take quite a white, as well as this the prototype code I’m adding may be temporary and is only a few lines.

If there is no prototype no conflict option how would I convert the below code, my javascript codes are limited?

// JavaScript Document
// calculate price based on quantity
function changeQty(change){
var currentQty = parseInt($F('quant')) // Where quant is the id of your quantity input field. Gets value of currentQty field

switch (change) {
    case 'add':
        currentQty += 1
        $('quant').value = currentQty
        calculate()
        break
    case 'subtract':
        if (currentQty > 1) { // only subtract if qty is greater than zero
            currentQty -= 1
            $('quant').value = currentQty
            calculate()
        }
        break
    case 'field':
        if (currentQty > 0) {
            window.setTimeout('calculate()', 500)
        }
        break
}
}
function calculate(){
var currentQty = parseInt($F('quant')) // Where quant is the id of your quantity input field. Gets value of currentQty field    
var jsnormalprice = $F('jsnormalprice') // Where jsnormalprice is the id of your hidden base price field. Gets value of base_price field    
var jsspecialprice = $F('jsspecialprice') // Where  is the id of your hidden base price field. Gets value of base_price field   

if (currentQty > 0) { // Don't want price to display if zero if customer zeros out quantity
    var new_jsnormalprice = jsnormalprice * currentQty // Calculate the price.      
    var new_jsnormalprice = new_jsnormalprice.toFixed(2) // Only allow 2 decimals. I'll let you add rounding features up or down.

    var new_jsspecialprice = jsspecialprice * currentQty // Calculate the price.        
    var new_jsspecialprice = new_jsspecialprice.toFixed(2) // Only allow 2 decimals. I'll let you add rounding features up or down.

} else { // set price back to original price
    new_jsnormalprice = jsnormalprice
    new_jsspecialprice = jsspecialprice
}   

$('jsnormalpriceshow').update(new_jsnormalprice) // Where jsnormalpriceshow is the id of your span for the echoed product price
$('jsspecialpriceshow').update(new_jsspecialprice) // Where jsspecialpriceshow is the id of your span for the echoed product price

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:41:29+00:00Added an answer on May 25, 2026 at 8:41 pm

    Prototype does not have a no conflict mode…

    I’ve converted your code, but I may have missed a spot or two…

    Generally, $('elemID') => $('#elemID') and $F('elemID') => $('#elemID').val() is what I’ve done..

    // JavaScript Document
    // calculate price based on quantity
    function changeQty(change){
    var currentQty = parseInt($('#quant').val()) // Where quant is the id of your quantity input field. Gets value of currentQty field
    
    switch (change) {
        case 'add':
            currentQty += 1
            $('#quant').val(currentQty)
            calculate()
            break
        case 'subtract':
            if (currentQty > 1) { // only subtract if qty is greater than zero
                currentQty -= 1
                $('#quant').val(currentQty)
                calculate()
            }
            break
        case 'field':
            if (currentQty > 0) {
                window.setTimeout('calculate()', 500)
            }
            break
    }
    }
    function calculate(){
    var currentQty = parseInt($('#quant').val()) // Where quant is the id of your quantity input field. Gets value of currentQty field    
    var jsnormalprice = $('#jsnormalprice').val() // Where jsnormalprice is the id of your hidden base price field. Gets value of base_price field    
    var jsspecialprice = $('#jsspecialprice').val() // Where  is the id of your hidden base price field. Gets value of base_price field   
    
    if (currentQty > 0) { // Don't want price to display if zero if customer zeros out quantity
        var new_jsnormalprice = jsnormalprice * currentQty // Calculate the price.      
        var new_jsnormalprice = new_jsnormalprice.toFixed(2) // Only allow 2 decimals. I'll let you add rounding features up or down.
    
        var new_jsspecialprice = jsspecialprice * currentQty // Calculate the price.        
        var new_jsspecialprice = new_jsspecialprice.toFixed(2) // Only allow 2 decimals. I'll let you add rounding features up or down.
    
    } else { // set price back to original price
        new_jsnormalprice = jsnormalprice
        new_jsspecialprice = jsspecialprice
    }   
    
    $('#jsnormalpriceshow').html(new_jsnormalprice) // Where jsnormalpriceshow is the id of your span for the echoed product price
    $('#jsspecialpriceshow').html(new_jsspecialprice) // Where jsspecialpriceshow is the id of your span for the echoed product price
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be a dumb question, I have tried googling but I am probably
I have tried googling for an way to do this but can't seem to
I guess the topic says it. I have tried googling this, but havent gotten
I've tried Googling and searching stackoverflow, but have yet to find a solution too
I have tried searching over the internet about this problem but not able to
Have tried to find solutions for this and can't really come up with anything.
I have tried this: #define format(f, ...) \ int size = strlen(f) + (sizeof((int[]){__VA_ARGS__})/sizeof(int))
I have tried many permutations but they all don't seems to work well. Am
I've done a bit of googling round but this particular problem is a little
I've tried Googling this, and there are so many answers based on various specific

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.