简单的jquery php数学实时更新文本字段

I have been working on this since 11am EST :/

Unable to find out where I am wrong, my java/jquery is non existent (trying to pick it up)

What I am trying to do is calculate litecoin's per day based on a few variables.

LTC/day = (50) * (24) * (24) ) / (User_hash/net_hash)

IE:

(block * 24 * 24) / (mhs / $ltcdiff) = LTC/day or total text field

here is the code, any light shed on it would be great, I am trying to get it to update live as you type the mhs rate into that field.

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

The php code can be ignored, it's pulling the right data, it seems to be just the javascript.

You need to reference JQuery to use JQuery functions. Also, make sure your JavaScript is rendered after the element you're targeting with JQuery:

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