Friday 15 March 2013

javascript - Hidden Inputs not Posting? -



javascript - Hidden Inputs not Posting? -

can tell me why of sudden of hidden inputs not posting when select "no" alternative 1 of 3 radio buttons on checkout table?

http://jsfiddle.net/#&togetherjs=o6vikmjqrb

heres table...

<table class="shop_table"> <thead> <tr> <th class="product-name">product</th> <th class="product-total">total</th> </tr> </thead> <tbody> <tr class="cart_item"> <td class="product-name"> <strong>demo holiday home</strong><br /><br />1 adults, 0 children<br />2014-11-21 2014-11-23 <strong class="product-quantity">&times; 1</strong> </td> <td class="product-total totaltexttop"> <span class="amount">&#36;1,000.00</span> </td> </tr> <tr class="cart_item"> <td class="product-name"> refundable harm deposit <span style="color: #ff0000;">(not taxed, not included in order total)</span> <br/><span style="color: #ff0000; font-size: 10px;">please note refundable harm deposit must paid within 45 days of reserved holiday check-in date.<br/>for international creditcard transactions there additional 6% surcharge.</span> </td> <td class="product-total refundabledamagedeposittexttop"> $<div id="pricedisplayrefundabledamagedeposit" class="pricedisplay">2,000.00</div> </td> </tr> <tr class="cart_item"> <td class="product-name"> cleaning fee </td> <td class="product-total"> $<div id="pricedisplaycleaningfee" class="pricedisplay">175.00</div> </td> </tr> <tr class="cart_item"> <td class="product-name"> city occupancy tax&nbsp;8% </td> <td class="product-total"> $<div id="pricedisplaytaxrate" class="pricedisplay">80.00</div> </td> </tr> <tr class="cart_item"> <td class="product-name"> preheat pool?&nbsp;&nbsp;<input type="radio" name="preheatpoolselect" id="preheatpoolyes" value="yes" onclick='showfee("pricedisplaypoolheating","200.00","poolheatingfee")' checked><label for="preheatpoolyes">yes</label>&nbsp;&nbsp;<input type="radio" name="preheatpoolselect" id="preheatpoolno" value="no" onclick='clearfee("pricedisplaypoolheating","poolheatingfee")'><label for="preheatpoolno">no</label> </td> <td class="product-total"> $<div id="pricedisplaypoolheating" class="pricedisplay">200.00</div> </td> </tr> <tr class="cart_item"> <td class="product-name"> have pet(s)?&nbsp;&nbsp;<input type="radio" name="havepetsselect" id="havepetsyes" value="yes" onclick='showfee("pricedisplaypetfee","150.00","petfee")' checked><label for="havepetsyes">yes</label>&nbsp;&nbsp;<input type="radio" name="havepetsselect" id="havepetsno" value="no" onclick='clearfee("pricedisplaypetfee","petfee")'><label for="havepetsno">no</label> </td> <td class="product-total"> $<div id="pricedisplaypetfee" class="pricedisplay">150.00</div> </td> </tr> <tr class="cart_item"> <td class="product-name"> property harm protection?&nbsp;&nbsp;<input type="radio" name="propertydamageprotectionselect" id="propertydamageprotectionyes" value="yes" onclick='showfee("pricedisplaypropertydamageprotection","80.00","propertydamageprotection")' checked><label for="propertydamageprotectionyes">yes</label>&nbsp;&nbsp;<input type="radio" name="propertydamageprotectionselect" id="propertydamageprotectionno" value="no" onclick='clearfee("pricedisplaypropertydamageprotection","propertydamageprotection")'><label for="propertydamageprotectionno">no</label> </td> <td class="product-total"> $<div id="pricedisplaypropertydamageprotection" class="pricedisplay">80.00</div> </td> </tr> <tr class="cart_item"> <td class="product-name"> reservation fee&nbsp;6% </td> <td class="product-total"> $<div id="pricedisplayreservationfee" class="pricedisplay">101.10</div> </td> </tr> <tr class="cart_item"> <td class="product-name"> <strong>vacation bundle total</strong> </td> <td class="product-total"> <strong>$<div id="pricedisplayvacationpackagetotal" class="pricedisplay">1,786.10</div></strong> </td> </tr> <!-- <tr class="cart_item"> <td class="product-name"> <span style="line-height:15px;">&nbsp;</span> </td> <td class="product-total"> </td> </tr> --> </tbody> <tfoot> <!-- <tr class="cart-subtotal"> <th>cart subtotal</th> <td>$1,356.10</td> </tr> --> <tr class="order-total"> <th>order total</th> <td>$<div id="pricedisplayvacationpackagegrandtotal" class="pricedisplay">1,786.10</div></td> </tr> </tfoot> </table>

heres form hidden inputs...

<form id='paypalcheckout' action='https://www.paypal.com/cgi-bin/webscr' method='post' style="margin-bottom: 10px"> <input type="hidden" name="item_name_1" value="demo holiday home" /> <input type="hidden" name="item_number_1" value="demo-vacation-home" /> <input type="hidden" name="amount_1" value="1000" /> <input type="hidden" name="quantity_1" value="1" /> <!--- <input type="hidden" name="item_name_" value="refundable harm deposit" /> <input type="hidden" name="item_number_" value="" /> <input type="hidden" name="amount_" value="" /> <input type="hidden" name="quantity_" value="1" /> --> <input type="hidden" name="item_name_2" value="cleaning fee" /> <input type="hidden" name="item_number_2" value="cleaning-fee" /> <input type="hidden" name="amount_2" value="175" /> <input type="hidden" name="quantity_2" value="1" /> <input type="hidden" name="item_name_3" value="6% reservation fee" /> <input type="hidden" name="item_number_3" value="6%-reservation-fee" /> <input type="hidden" name="amount_3" value="101.1" id="reservationfee"/> <input type="hidden" name="quantity_3" value="1" /> <input type="hidden" name="item_name_4" value="8% city occupancy tax" /> <input type="hidden" name="item_number_4" value="8%-city-occupancy-tax" /> <input type="hidden" name="amount_4" value="80" /> <input type="hidden" name="quantity_4" value="1" /> <input type="hidden" name="item_name_5" value="pool-heating fee" class="poolheatingfee"/> <input type="hidden" name="item_number_5" value="pool-heating-fee" class="poolheatingfee"/> <input type="hidden" name="amount_5" value="200" class="poolheatingfee"/> <input type="hidden" name="quantity_5" value="1" class="poolheatingfee"/> <input type="hidden" name="item_name_6" value="pet fee" class="petfee"/> <input type="hidden" name="item_number_6" value="pet-fee" class="petfee"/> <input type="hidden" name="amount_6" value="150" class="petfee"/> <input type="hidden" name="quantity_6" value="1" class="petfee"/> <input type="hidden" name="item_name_7" value="property harm protection" class="propertydamageprotection"/> <input type="hidden" name="item_number_7" value="property-damage-protection" class="propertydamageprotection"/> <input type="hidden" name="amount_7" value="80" class="propertydamageprotection"/> <input type="hidden" name="quantity_7" value="1" class="propertydamageprotection"/> <input type='hidden' name='business' value='juliocpreciado@gmail.com' /> <input type='hidden' name='shopping_url' value='http://www.dreamhomevacationrentals.com/cart/' /> <input type='hidden' name='lc' value='en_us' /> <input type='hidden' name='cmd' value='_cart' /> <input type='hidden' name='charset' value='utf-8'> <input type='hidden' name='upload' value='1' /> <input type='hidden' name='no_shipping' value='2' /> <input type='hidden' name='currency_code' value='usd' id='currency_code' /> <input type='hidden' name='custom' value='|||' /> <input type='hidden' name='notify_url' value='http://www.dreamhomevacationrentals.com/store/ipn/'> <input type='hidden' name='return' value='http://www.dreamhomevacationrentals.com/thank-you/' /> <input id='paypalcheckoutbutton' type='image' src='https://www.paypal.com/en_us/i/btn/btn_xpresscheckout.gif' value='checkout paypal' /> </form>

and here's javascript below form...

<script type="text/javascript"> //money formatter from... http://stackoverflow.com/questions/9318674/javascript-number-currency-formatting number.prototype.formatmoney = function(decplaces, thouseparator, decseparator) { var n = this, decplaces = isnan(decplaces = math.abs(decplaces)) ? 2 : decplaces, decseparator = decseparator == undefined ? "." : decseparator, thouseparator = thouseparator == undefined ? "," : thouseparator, sign = n < 0 ? "-" : "", = parseint(n = math.abs(+n || 0).tofixed(decplaces)) + "", j = (j = i.length) > 3 ? j % 3 : 0; homecoming sign + (j ? i.substr(0, j) + thouseparator : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thouseparator) + (decplaces ? decseparator + math.abs(n - i).tofixed(decplaces).slice(2) : ""); }; function recalculatereservationfee() { var vacationrentalprice = parsefloat(1000); var taxrate = parsefloat(document.getelementbyid("pricedisplaytaxrate").textcontent); var cleaningfee = parsefloat(document.getelementbyid("pricedisplaycleaningfee").textcontent); var poolheating = parsefloat(document.getelementbyid("pricedisplaypoolheating").textcontent); var petfee = parsefloat(document.getelementbyid("pricedisplaypetfee").textcontent); var propertydamageprotection = parsefloat(document.getelementbyid("pricedisplaypropertydamageprotection").textcontent); var reservationfeetarget = vacationrentalprice + taxrate + cleaningfee + poolheating + petfee + propertydamageprotection; var thenewreservationfee = parsefloat((6 * reservationfeetarget) / 100); var formattednewreservationfee = thenewreservationfee.formatmoney(2,',','.'); // illustration "$3,543.76" document.getelementbyid("pricedisplayreservationfee").innerhtml = formattednewreservationfee; document.getelementbyid("reservationfee").value = formattednewreservationfee; //document.write('<br/>the vars: <br/>' + vacationrentalprice + '<br/>' + cleaningfee + '<br/>' + taxrate + '<br/>' + poolheating + '<br/>' + petfee + '<br/>' + propertydamageprotection + '<br/>--<br/>' + reservationfeetarget + '<br/>' + formattednewreservationfee); function recalculategrandtotal() { var thegrandtotal = vacationrentalprice + taxrate + cleaningfee + poolheating + petfee + propertydamageprotection + thenewreservationfee; var formattedgrandtotal = thegrandtotal.formatmoney(2,',','.'); // illustration "$3,543.76" document.getelementbyid("pricedisplayvacationpackagetotal").innerhtml = formattedgrandtotal; document.getelementbyid("pricedisplayvacationpackagegrandtotal").innerhtml = formattedgrandtotal; } recalculategrandtotal(); } function clearfee(thenamedfee,thenamedclass){ document.getelementbyid(thenamedfee).innerhtml = '0.00'; var elems = document.getelementsbyclassname(thenamedclass); for(var = 0; < elems.length; i++) { elems[i].disabled = true; } recalculatereservationfee(); } function showfee(thenamedfee,somefee,thenamedclass){ document.getelementbyid(thenamedfee).innerhtml = somefee; var elems = document.getelementsbyclassname(thenamedclass); for(var = 0; < elems.length; i++) { elems[i].disabled = false; } recalculatereservationfee(); } </script>

you can add together 1 more script 1 run on button click .

<input id='paypalcheckoutbutton' type='image' src='https://www.paypal.com/en_us/i/btn/btn_xpresscheckout.gif' onclick="javascript:dosubmit();" value='checkout paypal' />

script

<script> function dosubmit(){ var j=1; (i =0; i<=27;i+=4) { if(document.getelementbyid('paypalcheckout')[i].disabled==false) { document.getelementbyid('paypalcheckout')[i].name='item_name_'+(j); document.getelementbyid('paypalcheckout')[i+1].name='item_number_'+(j); document.getelementbyid('paypalcheckout')[i+2].name='amount_'+(j); document.getelementbyid('paypalcheckout')[i+3].name='quantity_'+(j); j++; } } homecoming true; } </script>

javascript forms post paypal

No comments:

Post a Comment