I have input field to payment gate that creates URL, need to add "00" at the end of entered value. So right now when I type 150, value to url should go 15000, but user in input file should see still 150
<input type="text" style="width: 100%; height: 40px;" name="z24_kwota">
Full code:
<form action="https://sklep.przelewy24.pl/zakup.php" method="get"><input name="z24_id_sprzedawcy" type="hidden" value="xxx" /> <input name="z24_crc" type="hidden" value="xxx" /> <input name="z24_nazwa" type="hidden" value="xxx" /> <input name="z24_return_url" type="hidden" value="xxx" /> <input name="z24_language" type="hidden" value="pl" />
<table style="width: 100%;">
<tbody>
<tr>
<td><input type="text" style="width: 100%; height: 40px;" name="z24_kwota"></td>
</tr>
</tbody>
</table>
<p><input id="submit_button" type="submit" value="PAY" /><br /><br /></p>
</form>
CodePudding user response:
Start by handling the onsubmit event on the form (add onsubmit="something()"
):
<form action="https://sklep.przelewy24.pl/zakup.php" method="get" onsubmit="mySubmit()">
Then do what you need in the handler:
function mySubmit() {
var el = $("[name=z24_kwota]");
var val = el.val();
val *= 100;
el.val(val);
}
When the user clicks the submit button, the onsubmit
event on the form is triggered which calls the mySubmit
function. This function alters the value of the element in question (makes 150 => 15000) by multiplying by 100.