gpt4 book ai didi

javascript - 如何使用JS使用更新值自动更新第二个文本框

转载 作者:行者123 更新时间:2023-11-30 13:25:14 26 4
gpt4 key购买 nike

我有一个 PHP 脚本和两个文本框。它是一种货币转换。

如果用户想使用第一个文本框购买 1 个信用额度,即 5 美元,然后点击选项卡,下一个文本框将通过乘以 php 变量自动更新。

可以使用简单的内联 JavaScript 吗?

我的 PHP 变量是 $currentValue

第一个测试框是 name & id="credit"
第二个文本框是 name & id="finalRupee"

请在 function.php 文件中查看以下代码

<form action="index.php" method="post" name="userFormJob" onSubmit="return   validateForm()" enctype="multipart/form-data">
<table width= "100%">
<tr>
<td colspan="2"><strong><?php echo JText::_( 'PRICE FOR 1 CREDIT' ); ?> = <?php echo $currencytype . ' ' . $currency.' '; ?> &nbsp;<?php echo $price_credit; ?> (Please Note: For One credit value you can post 1 Job for 1 Day)</strong></td>
</tr>
<tr>
<td><p> <b>
<?php
$content = file_get_contents("http://www.xe.com/ucc/convert.cgi?From=USD&To=INR& Amount=1.&template=pca-xetrade");
$content = explode('<TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0>',$content);
$content = str_replace('<TD VALIGN=MIDDLE ALIGN=RIGHT><FONT FACE="Arial,Helvetica"><B>', "", "$content[1]");
$content = explode('<TD COLSPAN=3 ALIGN=CENTER><FONT FACE="Arial,Helvetica" SIZE=-2>',$content);
$toremove = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", ">", "<", "\"", "\'", "=", ",", "/", "-1");

$content = str_replace($toremove, "", "$content[0]");
$final = explode('+1',$content);

$from_code = "USD";
$to_code = "INR";
$currency = $config-> get('currency');

echo '<b>' .$final[0]. ' ' .$from_code. ' =' .$final[1]. ' ' .$to_code. '</b>';
?>
</b></p></td>
</tr>
<tr>
<td><?php echo JText::_( 'BUY' ); ?></td>
<td><input type="text" name="credit" id="credit" class="inputbox" onKeyPress="return isNumberKey(event)" />
<?php
$currentValue = $final[1];
?>
<?php echo JText::_('CREDIT'); ?>
<input name="finalRupee" type="text" class="inputbox" id="finalRupee" onKeyPress="return isNumberKey(event)" value="<?php ?>" readonly /></td>
</tr>
<tr>
<td colspan="2" >Please Use Currency Convert for Dollar to Rupees <a href="http://www.xe.com/ucc/convert.cgi?Amount=1&From=USD&To=INR&template=8n" target="_blank">Click Here</a></td>
</tr>
<tr>
<td colspan="2" ><b><?php echo JText::_('BILLING ADDRESS'); ?></b></td>
</tr>
<tr>
<td><?php echo JText::_('ADDRESS'); ?></td>
<td><input class="inputbox" type="text" name="address" id ="address" size="40" maxlength="255" value="<?php echo $row->bill_addr; ?>"/></td>
</tr>
<tr>
<td><?php echo JText::_('ADDRESS CONT'); ?>:</td>
<td><input class="inputbox" type="text" size="40" maxlength="255" name="address_cont" id ="address_cont" value="<?php echo $row->bill_addr_cont; ?>"/></td>
</tr>
<tr>
<td><?php echo JText::_('CITY'); ?>: </td>
<td><input class="inputbox" type="text" name="city" id ="city" value="<?php echo $row->bill_city; ?>"/></td>
</tr>
<tr>
<td><?php echo JText::_('STATE'); ?>:</td>
<td><input class="inputbox" type="text" name="state" id ="state" value="<?php echo $row->bill_state; ?>"/></td>
</tr>
<tr>
<td><?php echo JText::_('COUNTRY'); ?>:</td>
<td><?php
$list_country = getSelectCountry('id_country',$row->bill_id_country,'');
echo $list_country;
?></td>
</tr>
<tr>
<td><?php echo JText::_('ZIP POSTAL'); ?>:</td>
<td><input class="inputbox" type="text" name="zip" id ="zip" value="<?php echo $row->bill_zip; ?>"/></td>
</tr>
<tr>
<td><?php echo JText::_('PHONE'); ?>:</td>
<td><input class="inputbox" type="text" name="phone" id ="phone" value="<?php echo $row->bill_phone; ?>"/></td>
</tr>
<tr>
<td><?php echo JText::_('PAYMENT'); ?>:</td>
<td><select name="mode_pay">
<option value="m"><?php echo JText::_('MANUAL'); ?> / <?php echo JText::_('TRANSFER'); ?></option>
<option value="p">PayPall Secure Pay</option>
</select></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2"><center>
<img src="http://www.jobodisha.com/images/stories/powered_by.png" alt="Pay Pal Secure Payments" width="497" height="149" align="absmiddle">
</center></td>
</tr>
</table>
<input type="submit" value="<?php echo JText::_( 'BUY' ); ?>" class="button" />
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="task" value="savebuycredit" />
<input type="hidden" name="boxchecked" value="0" />
<?php echo JHTML::_('form.token'); ?>
</form>

最佳答案

您不需要 php 来进行简单的乘法计算。简单的内联 jquery 代码是:

var individualCost= 5;
var amount = $("#credit").val();
$("#finalRupee").val(amount * individualCost);

关于javascript - 如何使用JS使用更新值自动更新第二个文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8748702/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com