Bitcoin Forum

Bitcoin => Bitcoin Discussion => Topic started by: frontlineassembly on April 23, 2011, 12:57:02 AM



Title: JSON/webform nub question (exchanging psc to btc)
Post by: frontlineassembly on April 23, 2011, 12:57:02 AM
i have a shitty form:

Code:
<script language="JavaScript">
<!--
function CalculateTotals(){
f=document.orderform;
f.total1.value=parseInt(f.qty1.value)*1.14;
f.total2.value=parseInt(f.qty2.value)*1.1;
f.total3.value=parseInt(f.qty3.value)*0.90;
f.total4.value=parseInt(f.qty4.value)*0.95;
f.grandtotal.value=parseInt(f.total1.value)
+parseInt(f.total2.value)
+parseInt(f.total3.value)
+parseInt(f.total4.value)-2;}
//-->
</script></head>
<body>
<form name="orderform" method="post" action="formprocessor">
<table border="3"><tr>
<th>Amount</th><th>Currency</th><th>Voucher</th>
<th>Value in USD</th><th>Total USD</th></tr>
<tr><td>
<input name="qty1" size="3" OnBlur="CalculateTotals()" /></td>
<td>EUR</td><td>Ukash</td>
<td align="right">1.14</td>
<td><input name="total1" size="7"
OnFocus="document.orderform.qty2.select();
document.orderform.qty2.focus();" /></td></tr>
<tr><td>
<input name="qty2" size="3" OnBlur="CalculateTotals()" /></td>
<td>EUR</td><td>PaySafeCard</td>
<td align="right">1.1</td>
<td><input name="total2" size="7"
OnFocus="document.orderform.qty3.select();
document.orderform.qty3.focus();" /></td></tr>
<tr><td>
<input name="qty3" size="3" OnBlur="CalculateTotals()" /></td>
<td>USD</td><td>CashU or WMZ card</td>
<td align="right">0.90</td>
<td><input name="total3" size="7"
OnFocus="document.orderform.qty4.select();
document.orderform.qty4.focus();" /></td></tr>
<tr><td>
<input name="qty4" size="3" OnBlur="CalculateTotals()" /></td>
<td>USD</td><td>MoneyPack</td>
<td align="right">0.95</td>
<td><input name="total4" size="7"
OnFocus="document.orderform.qty1.select();
document.orderform.qty1.focus();" /></td></tr>
<tr><td></td><td></td><td></td>
<td align="right">Fee</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$2</td></tr>
<tr><td></td><td></td><td></td>
<td align="right"><b>RECEIVE THIS MANY BITCOINS:</b></td>
<td><input name="grandtotal" size="7"
OnFocus="document.orderform.qty1.select();
document.orderform.qty1.focus();" /></td></tr>
</table>
<input type="hidden" value="2" name="sh" />
</form>
<script language="JavaScript">
<!--
f=document.orderform;
f.qty1.value=0; f.qty2.value=0;
f.qty3.value=0; f.qty4.value=0;
f.total1.value=0; f.total2.value=0;
f.total3.value=0; f.total4.value=0;
f.sh.value=0;
f.grandtotal.value=0;
//-->
</script>

Basically I need to call the json feed from btcex or mtgox to convert the total USD to BTC.
advice? I can haz totals?


Title: Re: JSON/webform nub question (exchanging psc to btc)
Post by: asdf on April 23, 2011, 04:17:53 AM
You'll have to pull the exchange rate from the server. cross site ajax requests aren't allowed by the browser.