Requesting help with javascript

Hi every one…! A newbee on javascript here…

I am trying to set up adult price and children price as well as number of travelers in the two groups (adults vs children traveling together!) in order to obtain total cost on submission of reservation form/payment form. I am planning to use the completed form on paypal payments. I have done some research and developed the javascript to where I can see some numbers (mostly ratios of the two prices) but I do not have an idea on how to separate the two options, i.e., the number of adults and their total price … from the number of children, and their total price which is supposed to be half of the adult travel cost; before the two totals are added. Below is an example of where I have reached but cant crack it to completion. I need your help!

<label><input type="radio" name="os0" value="travel-package" checked="checked">: - Select a Package</label>
 <label><input type="radio" name="os0" value="Carribean cruise">: $15,995.95 - Florida to 
 <label><input type="radio" name="os0" value="Everest Climb">: $11,300.00 - Everest 
 <label><input type="radio" name="os0" value="European tour">: $11,450.00 - European 

<select name="travel package" id="select2-basic" class="#"> 
  <option value="Carribean cruise">Caribean Cruise</option>                
  <option value="Everest Climb">Everest Climb</option>
  <option value="European tour">European Tour</option>
<p>Adult:<select name="Quantity" id="select2-basic" value="#">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>

<p>Children:<select name="Children" id="select3-basic" value="#">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>

<input class="span1" readonly type="text" name="Visitors" value=""> </br></br>

<input class="span1" readonly type="text" name="Price" value="">

<input class="span1" readonly type="text" name="Children" value=""> </br></br>

<input class="span1" readonly type="text" name="Price" value=""></br></br>

<script src=""></script>


    var prices = {
         var prices = {
        'Caribean Cruise':15996,'Everest Climb':11300,'European tour':11450
    $('#select2-basic, #select3-basic').on('change', function() {

        if( == 'Quantity') {


        $('input[name="Price"]').val(prices[$('#select2-basic').val()] ? (prices[$('#select2-
        basic').val()] * this.value) :  (1 * this.value));
 else if( == 'Children') {

         $('input[name="Children"]').val(+this.value * .5);
	 $('input[name="Price"]').val(prices[$('#select3-basic').val()] ? (prices[$('#select2-
        basic').val()] * this.value) :  (.5 * this.value));		

 <input type="hidden" name="item_name" value="Safari">
 <input type="hidden" name="tax_rate" value="1.17">
 <input type="hidden" name="shipping" value="4.35">
 <input type="hidden" name="business" value="">


 <!--<input type="hidden" name="cmd" value="_cart">
 <input type="hidden" name="lc" value="US">
 <input type="hidden" name="button_subtype" value="safari">
 <input type="hidden" name="no_note" value="0">
 <input type="hidden" name="add" value="1">
 <input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_LG.gif:NonHostedGuest">
 <input type="hidden" name="currency_code" value="USD"> 
 <input type="hidden" name="option_index" value="0">
 <input type="hidden" name="on0" value="Type">
 <input type="image" name="submit" src="" alt="ePayment">
 <img src="" width="1" height="1"  alt="">-->



NOTE: Please show how to link the edited avove code to an event controller script; such as “on Click”.

You help is highly appreciated. Thank you.

It looks like your HTML is missing a couple of opening tags early on, the one for the <form> being the most obvious one.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.