Please me complete my javascript code!


Hi every one..! A newbee on javascript here..

I am trying to set up adults' prices and children's prices that must correspond to numbers and prices of travelers in the two groups (adults vs children traveling together!) in order to obtain total cost; before submission of reservation form/payment form. I am planning to use the completed form on paypal payments. I have done some research and developed my code to where it is now. But being a new bee, I do not have an idea on how to develop code to fill the last result box for Prices1, which is the price for a number of children! I am able to select their number.. but I cant get to relate their number to obtain their price total (children's). The price for children is supposed to be half that of the adult price. 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>Adults:<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="Price1" 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="Price1"]').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 above code to an event controller script; such as "on Click".

You help is highly needed.

Thank you.


you created 2 objects with same name prices maybe?