Php 计算器创建jquery
我已经用php创建了计算器。现在我想要jquery中的计算器代码,使用相同的函数,相同的公式,所有的php都是什么。我需要编写jquery计算器。我是jquery新手。我不知道这是否可能。有人请帮帮我吗 我的php代码:Php 计算器创建jquery,php,jquery,Php,Jquery,我已经用php创建了计算器。现在我想要jquery中的计算器代码,使用相同的函数,相同的公式,所有的php都是什么。我需要编写jquery计算器。我是jquery新手。我不知道这是否可能。有人请帮帮我吗 我的php代码: <?php /* * Template Name: Calculator-iFrame */ get_header();?> <!-- Main Content --> <div class="large-12 colum
<?php
/*
* Template Name: Calculator-iFrame
*/
get_header();?>
<!-- Main Content -->
<div class="large-12 columns" role="content">
<?php
if (isset($_POST['valuea'])) $valuea = $_POST['valuea'];
if (isset($_POST['valueb'])) $valueb = $_POST['valueb'];
if (isset($_POST['valuec'])) $valuec = $_POST['valuec'];
if (isset($_POST['valued'])) $valued = $_POST['valued'];
if (isset($_POST['valuee'])) $valuee = $_POST['valuee'];
if (isset($_POST['valuef'])) $valuef = $_POST['valuef'];
$answera = (($valueb / $valuea) + ($valued / $valuec) + ($valuef / $valuee)) / 3;
echo <<<_END
<form method='post' action='http://whatsmyrealrate.com/solutionreach'>
<table class="calculator" border='0' width='500px' cellpadding='3' cellspacing='1' class="table">
<tr class="calcheading"><td colspan="3" align="center">Whats your effective rate?</td></tr>
<tr class="monthheading"><td colspan="2"><strong>Month 1</strong></td></tr>
<tr class="calcrow"><td>Total Sales, Including Amex</td><td align="center"><input type='text' name='valuea' value="$valuea"/></td></tr>
<tr class="calcrow2"><td>Total Fees, less any terminal or rental fees</td><td align="center"><input type='text' name='valueb' value="$valueb"/></td></tr>
<tr class="monthheading"><td colspan="2"><strong>Month 2</strong></td></tr>
<tr class="calcrow"><td>Total Sales, Including Amex</td><td align="center"><input type='text' name='valuec' value="$valuec"/></td></tr>
<tr class="calcrow2"><td>Total Fees, less any terminal or rental fees</td><td align="center"><input type='text' name='valued' value="$valued"/></td></tr>
<tr class="monthheading"><td colspan="2"><strong>Month 3</strong></td></tr>
<tr class="calcrow"><td>Total Sales, Including Amex</td><td align="center"><input type='text' name='valuee' value="$valuee"/></td></tr>
<tr class="calcrow2"><td>Total Fees, less any terminal or rental fees</td><td align="center"><input type='text' name='valuef' value="$valuef"/></td></tr>
<tr class="submit"><td colspan="3" align="center"><input type='submit' value='Calculate'/></td></tr>
_END;
?>
<tr class="calcrow">
<td colspan="3" align="center"><?php
if ($answera > .0238): {
echo "Your Effective Rate: <br></br>";
echo round($answera*100,2);
}
elseif ($answer == 0): {
echo "Your Effective Rate: <br></br>";
echo "0.00%";
}
else: {
echo "<strong>Oops, something has gone terribly wrong!</strong> <br></br>
Please attach at least 2 months of your most recent credit card processing statements and one of our specialists will respond within 24 hours with an accurate cost analysis.";
echo gravity_form( 1, false, false, false, '', false );
}
endif
?>
</td></i>
</tr>
</table>
</form>
</div>
<!-- End Main Content -->
<?php ?>
除了您使用费率的具体示例之外:下面是一个一般性说明,它仅展示了如何制作平方根计算器。您可以扩展它以满足您的需要。通常,您需要遵循以下步骤:
- 在呈现计算器的HTML页面中包含jquery.js
- 在HTML中有用户输入值的
字段(或使用
等)。确保使用type=“number”
作为字段id,稍后将重复使用id=“…”
- 使用占位符显示结果,例如,
。同样,计算结果将显示在此处。
用于标识此元素,以便您可以使用Javascript输入值id=“…”
- 使用一些按钮进行计算,例如
sqrt\u stuff()
将使用JQuery拾取值并粘贴结果;例如:
function sqrt_stuff() {
// Get user input from field with id "mynum"
var nr = $('#mynum');
// Calculate root
var root = Math.sqrt(nr);
// Show in div with id "result"
$('#result').html('The answer is: ' + root);
}
这个网站不是为你写代码的。为此雇佣一个人。我不是在要求写代码。我是在问你有什么想法或者有没有可能创建jquery