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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:39:52+00:00 2026-05-26T07:39:52+00:00

Im doing a form where you can fill in personal information and select products.

  • 0

Im doing a form where you can fill in personal information and select products. It dynamically adjusts the prices with some simple java scripts and eventually puts out all the information in a PDF file.

Now I have to implement a bonus code. Like when you put in “BONUS2011” you get 20% on all selected products. It has to by dynamic. Like the moment you correctly fill in the bonus field you get the 20% on the prices.

My question is now what is the easiest and most simpliest way to do this? I could just store the bonus code in the .js but thats of course not an ideal solution. My knowledge in Javascript and PHP is very limited (as you mightve noticed).

Thanks in advance!

  • 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-26T07:39:53+00:00Added an answer on May 26, 2026 at 7:39 am

    Since you have no code snippet, I’m going to do a very rough example of what you can do. Just make sure that the information you use to charge the customer is calculated correctly after s/he posts and that you don’t rely on a Total field from the form to determine what to charge them (since that can be manipulated when it’s posted).

    Do not put the bonus code in the JavaScript as everyone will be able to view it.

    Rather implement an AJAX call to update the price field. There are plenty of examples out there. It’s also easier if you use a JavaScript library like jQuery (http://www.jquery.com).

    • AJAX, refresh INPUT field
    • https://encrypted.google.com/search?q=use+ajax+to+update+an+input+box

    With jQuery it’s really easy:

    // HTML
    <!-- Bonus Code goes here -->
    <input type="text" id="bonus_code" />
    
    <!-- Contains the full price for the products -->
    <input type="hidden" id="full_price" value="100.00" />
    
     <!-- Contains the display price for the products -->
    <input type="text" id="display_price" readonly value="100.00" /> USD
    
    // JavaScript
    $(document).ready(function()
    {
        $('#bonus_code').change(function()
        {
            $.get('calculate_price.php',
                {
                    bonus_code: $(this).val(),
                    full_price: $('#full_price').val()
                },
                function(result)
                {
                    $('#display_price').val(result);
                }
            );
        });
    });
    
    // calculate_price.php
    <?php
    $bonus_code = $_GET['bonus_code'];
    $full_price = (float)$_GET['full_price'];
    if ($bonus_code == 'BONUS2001')
    {
        echo $full_price / 100 * 80; // output the new price
    }
    else
    {
        echo $full_price;
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing some geocoding using the google maps API. The user fill a form
what I am doing is creating a form using JSON this form can then
Can't figure what I am doing wrong. When I post my form there are
For example, if I'm doing some form input validation and I'm using the following
I'm doing a filter form in symfony2 and I try to preselect some filds.
I'm doing some automation work and can make my way around a site &
I want to pass some fields (for example like name information) into a form.
Greetings! I'm doing a Form on ASP.NET MVC 2, in my view I have
I'm doing a windows form and would like an audit task to happen every
I'm doing jquery small animation of fade in to form validation This is working

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.