تسجيل الدخول | التسجيل | الأسئلة المتكررة
Anonymous

Please HELP with getting TOTAL and submit to paypal account!

+ إضافة رد

مشاركة واحده صفحة 1 من 1


Please HELP with getting TOTAL and submit to paypal account!

بواسطة MABOBISH » الاثنين يوليو 31, 2017 3:32 pm

Hi I am a new bee on javascript.

All sorts of inputs and suggestions are welcome:-


After looking up a lot of examples I have come up with this code for my site, posted below.
I am trying to set up adults' prices and children's prices that must correspond to total numbers and prices of travelers in the two groups (adults vs children traveling together!) in order to obtain total cost; I am seeking help in making the below code be able to sum up the total of prices for adults and children in two text boxes (id="select2-basic" and id="select4-basic"), before submission to a paypal account indicated below. 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 Total Price, which is the total travel cost. The price for children {costs} is supposed to be half that of the adult price{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">: $996 - Florida to
Antigua</label>
<label><input type="radio" name="os0" value="Everest Climb">: $1300 - Everest
Climb</label>
<label><input type="radio" name="os0" value="European tour">: $11,450.00 - European
tour</label>


<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>

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

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




<input class="span1" readonly type="text" name="Price" id="select2-basic" value="">

<input class="span1" readonly type="text" name="costs" id="select4-basic" value=""></br></br>


<script src="https://code.jquery.com/jquery-3.1.1.js"></script>


<script>

$(function(){

var prices = {
'Caribean cruise':996,'Everest Climb':1300,'European Tour':1450
};



$('#select2-basic, #select3-basic').on('change', function(){
if(this.name == 'Quantity'){
$('input[name="Visitors"]').val(+this.value);
$('input[name="Price"]')
.val(prices[$('#select2-basic').val()] ? (prices[$('#select2-basic').val()] * this.value) : (1 * this.value));
};
});
});

</script>



<script>

$(function(){

var costs = { 'Caribean cruise':498,'Everest Climb':650,'European Tour':725

};

$('#select2-basic, #select5-basic').on('change', function(){
if (this.name == 'Children'){
$('input[name="Children"]').val(+this.value);
$('input[name="costs"]')
.val(costs[$('#select2-basic').val()] ? (costs[$('#select2-basic').val()] * this.value) : (.5 * this.value));
};
});
});

</script>



<script> // HELP NEEDED HERE!

function sum()
{
var txtFirstNumberValue = document.getElementById('select2-basic').value;

var txtSecondNumberValue = document.getElementById('select4-basic').value;

var result = parseInt(txtFirstNumberValue) + parseInt(txtSecondNumberValue);

if(txtFirstNumberValue=="" ||txtSecondNumberValue=="")

{
document.getElementById('sum').value = 0;
}

if (!isNaN(result))

{
document.getElementById('sum').value = result;
}
} // HELP HUMBLY NEEDED..THX!

</script>



<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="travel_sales@mybusiness.com">

******************************************************************************************************

<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="https://www.paypalobjects.com/webstatic/en_US/i/btn/png/btn_buynow_107x26.png" alt="ePayment">
<img src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1" alt="">

</fieldset>

</form>

</html>



You help is highly needed.

Thank you.
صورة العضو الشخصية

MABOBISH

  • مشاركات: 1
  • اشترك في: الثلاثاء يوليو 25, 2017 4:29 pm


+ إضافة رد

صفحة 1 من 1

cron