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 1107941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:00:29+00:00 2026-05-17T02:00:29+00:00

I have a registration form where a customer selects their desired package via a

  • 0

I have a registration form where a customer selects their desired package via a dropdownlist. They then select whether they wish to avail of a multiyear discount by choosing Yes or No radio buttons. If the yes radio button is selected, a dropdownlist is shown (using javascript) with a selection of years 1-3.
I’m not familar at all with javascript, and what I need to do next is when the customer selects year 1, 2, 3 for multiyear discounts, to calculate this discount, and show in a label beside the dropdownlist OR hide this label if the customer has selected no to multiyear discounts.

Here is my existing code:
Javascript to hide the yearly discount dropdownlist

<script type='text/javascript'>

$(function(){

 $('#discountselection').hide();

    $('#No').click(function(){
        $('#discountselection').hide();
    });

    $('#Yes').click(function(){
        $('#discountselection').show();
    });

});

</script>

And here is the HTML code:

        <td width="343">Package*</td>

        <td colspan="4">

        <select class="purple" name="package">

            <option value="Standard">Standard - &euro;55 Monthly</option>

            <option value="Premium" selected="selected">Premium - &euro;99 Monthly</option>

            <option value="Platinum">Platinum - &euro;149 Monthly</option>

        </select>

        </td>

        <tr>

        <td width="343">Would You like to avail of our multiyear discounts?*

        <br />See <a href="#dialog" name="modal">Pricing</a> for more details

        </td>

        <td colspan="4">

            <input name="discount" type="radio" id="Yes" value="Yes" />Yes

            <input name="discount" type="radio" id="No" value="No" checked="checked" />No<br />  

            <select name="discountselection" class="purple" id="discountselection">

                <option value="1" selected="selected">1 Year</option>

                <option value="2">2 Years</option>

                <option value="3">3 Years</option>  

            </select>                  

        </td>

This would be the IF statement I would need to execute within the javascript to calculate the price:

if package == "standard" && discountselection == "1"
{
    cost = 45 * 12;
    //display cost in label
}   
elseif package == "standard" && discountselection =="2"
{
    cost = 45 * 24; 
    //display cost in label
}
elseif package == "standard" && discountselection =="3"
{
    cost = 45 * 36;
    //display cost in label
}
elseif package == "premium" && discountselection =="1"
{
    cost = 85 * 12; 
    //display cost in label
}
elseif package == "premium" && discountselection =="2"
{
    cost = 85 * 24;
    //display cost in label
}
elseif package == "premium" && discountselection =="3"
{
    cost = 85 * 36;
    //display cost in label
}
elseif package == "platinum" && discountselection =="1"
{
    cost = 134 * 12;
    //display cost in label 
}
elseif package == "platinum" && discountselection =="2"
{
    cost = 134 * 24;
    //display cost in label
}
else package == "platinum" && discountselection =="3"
{
    cost = 134 * 36;
    //display cost in label
}

I am just unsure how to create this IF statement within Javascript. If anyone could offer any advice, help, or links to tutorials that could help me in this, I’d be very grateful.

  • 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-17T02:00:29+00:00Added an answer on May 17, 2026 at 2:00 am

    I hope that I understood your question correctly, but you’re trying to display a label with the costs if the user selected a value from your select box.

    If you can accomplish this by using the change event (provided by jQuery).

    $("#discountselection").change(function()  { 
        var product_cat = $("#package option:selected").val();
    
        if(product_cat == "standard") {
           product_prefix = 45;
        } else if (product_cat == "premium") {
           product_prefix = 85;
        } else if (product_cat == "platinum") {
           product_prefix = 134;
        }
    
        var selected_value = $("#discountselection option:selected").val();
        var cost = product_prefix * (12 * selected_value);
        $("#costlabel").val(cost);
    }); 
    

    But please be aware that you should double check these values on the server!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this registration form which is then validated using "bassistance's" validate.js: $('#pForm').validate({ rules:
I have a registration form if username does not exist in database then it
I have a registration form that a user can access via invitation. For example,
I have registration form where users can register their accounts with subdomain i.e. .mysite.com
I have a registration form that users fill with their email address (and password).
I currently have a registration form which checks a persons date of birth via
I am modifying my login/registration form via login.phtml and have a problem with the
In my web application i have registration form, when user register i want to
I have a registration form with common registration fields and two multiple selection Lists
I have a registration form leveraging xVal to handle all validation on the form.

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.