dom - Dynamically updating PayPal currency and amount feilds using javascript function -
dom - Dynamically updating PayPal currency and amount feilds using javascript function -
i trying dynamically update amount , currency value fields in next paypal purchase form based on radio button selection using function below. unable pass currency , amount values form. grateful if advise script error is.
the form:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top" name="f" id="f"> <input name="audio-book" type="radio" class="sum" value="54.95" checked="checked" /> nz$ 54.95 <input name="audio-book" type="radio" class="sum" value="43.95" /> au$ 43.95 <input name="audio-book" type="radio" class="sum" value="45.00" /> us$ 45.00 <input name="audio-book" type="radio" class="sum" value="34.95" /> eu€ 34.95 <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="xxxxxxxxxx"> <input type="hidden" name="lc" value="nz"> <input type="hidden" name="item_name" value="xxxxxxxxx"> <input type="hidden" name="amount" id="amount" value=""> <input type="hidden" name="currency_code" id="currency_code" value=""> <input type="hidden" name="button_subtype" value="services"> <input type="hidden" name="no_note" value="0"> <input type="hidden" name="cn" value="add special instructions seller:"> <input type="hidden" name="no_shipping" value="2"> <input type="hidden" name="rm" value="1"> <input type="hidden" name="return" value="xxxxx"> <input type="hidden" name="cancel_return" value="xxxxxx"> <input type="hidden" name="bn" value="pp-buynowbf:btn_buynowcc_lg.gif:nonhosted"> <input type="image" class="alignleft wp-image-2884 size-full" src="../uploads/btn_buynow_pp_142x27.png" border="0" name="submit1" id="button" onclick="javascript:dosubmit();" alt="paypal - safer..."> <img alt="" border="0" src="https://www.paypalobjects.com/en_us/i/scr/pixel.gif" width="1" height="1"> </form>
and function:
<script> function dosubmit(){ var $cost=0; var $code=""; var $currency=['nzd', 'aud', 'usd', 'eur']; var parent = document.getelementsbyclassname('sum'); (i = 0; i<parent.length; ++i){ if(parent[i].checked === true){ cost = number(parent[i].value); code = currency[i];} } document.getelementbyid('amount').value = cost; document.getelementbyid('currency_code').value = code; document.getelementbyid('f').submit(); homecoming true; } </script>
it seems fine code . thing need alter in script below line :
currently have :
code = currency[i];
change :
code = $currency[i];
i tried @ end , worked .
javascript dom paypal
Comments
Post a Comment