如何在文本框中自动为用户定义的金额添加百分比? [英] How do I automatically add a percentage to user defined amount in textbox?

查看:150
本文介绍了如何在文本框中自动为用户定义的金额添加百分比?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张表单供客户输入发票号和金额,并在点击提交按钮并重定向到支付网关之前选择付款方式。



这一切都很完美,但是,我需要能够自动将3%的值添加到金额文本框中输入的值,并将新值放在只读文本框(总计)中,但仅限于客户选择Visa或万事达卡时。 br />






例如:



发票号码(文本框) - 12345



付款方式(下拉) - 签证/万事达卡



发票金额(文本框) - 100英镑



总计(只读文本框) - 103英镑(含3%附加费)







我的代码如下:



I have a form for customers to enter their invoice number and amount, and choose their payment method before clicking the submit button and redirecting to the payment gateway.

This all works perfectly, however, I need to be able to automatically add 3% to the value entered in the amount textbox, and place the new value in a readonly textbox (total), but only when a customer selects Visa or Mastercard.



Example:

Invoice Number (Textbox) - 12345

Payment Type (Dropdown) - Visa/Mastercard

Invoice Amount (Textbox) - £100

Total (Readonly Textbox) - £103 (inc. 3% surcharge)



My code is as follows:

<form action="" name="" method="POST">
				
<input type="text" name="cartId" placeholder="Invoice Number">

<select name="paymentType">
	<option>Payment Method</option>
	<option value="MSCD">Mastercard</option>
	<option value="DMC">Mastercard Debit</option>
	<option value="MAES">Maestro</option>
	<option value="VISA">Visa</option>
	<option value="VISD">Visa Debit</option>
	<option value="VIED">Visa Electron</option>
</select>

<input type="text" name="amount" placeholder="Amount">

<input type="text" name="total" value="" readonly>
				
<input type="submit" value="Pay Now" class="wpcf7-submit">
				
			
</form>

推荐答案

请参阅: http ://stackoverflow.com/questions/14525393/format-percentage-using-php [ ^ ]


这篇关于如何在文本框中自动为用户定义的金额添加百分比?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆