我在美国东部时间上午11点开始研究这个问题:/
无法找出我错在哪里,我的java / jquery不存在(试图把它拿起来)
我要做的是根据一些变量计算每天的litecoin。
LTC/day = (50) * (24) * (24) ) / (User_hash/net_hash)
IE:
(block * 24 * 24) / (mhs / $ltcdiff) = LTC/day or total text field
这里是代码,任何关于它的灯都会很棒,我试图让你在你输入mhs速率时更新它。
<?
$jsonurl = "http://www.litehosting.org/API/LTC/litecoin.php";
$json = file_get_contents($jsonurl,0,null,null);
$data = json_decode($json, true);
$dat = $data['return']['getinfo'];
$ltcdiff = $dat['difficulty'];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
$('input').keyup(function(){
var mhs = $('input[name="hash"]').val(),
diff = $('input[name="diff"]').val(),
block = ('50'),
result;
if (mhs != "" && diff != "" && block != ""){
result = ((block*24) * (24)) / ((mhs) / (diff));
$('input[name="total"]').val(result);
}
});
</script>
</head>
<body>
<h1>LTC example</h1>
<form name="myForm">
<P> mh/s: </P>
<input type="text" name="hash"><BR>
<P> diff: </P>
<input type="text" name="diff" value="<? echo $ltcdiff;?>"><BR>
<P> total coin: </P>
<input type="text" name="total">
<BR>
</form>
</body>
</html>
可以忽略php代码,它正在拉动正确的数据,它似乎只是javascript。
答案 0 :(得分:1)
您需要引用JQuery来使用JQuery函数。另外,请确保在使用JQuery定位的元素之后呈现JavaScript:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js" type="text/javascript"></script>
<title>Untitled Document</title>
</head>
<body>
<h1>LTC example</h1>
<form name="myForm">
<P> mh/s: </P>
<input type="text" name="hash"><BR>
<P> diff: </P>
<input type="text" name="diff" value="<? echo $ltcdiff;?>"><BR>
<P> total coin: </P>
<input type="text" name="total">
<BR>
</form>
<script type="text/javascript">
$('input').keyup(function(){
var mhs = $('input[name="hash"]').val(),
diff = $('input[name="diff"]').val(),
block = ('50'),
result;
if (mhs != "" && diff != "" && block != ""){
result = ((block*24) * (24)) / ((mhs) / (diff));
$('input[name="total"]').val(result);
}
});
</script>
</body>
</html>