1
I am trying to put the value of "10" to the value of a variable, You will be able to open the button with this code however the value 10 (quantity of product) but it is not being changed, if I just change the 10 by 20, when opening the button will be 20 the amount, however I want to change with the script because I am creating a system that changes the values depending on the selected option.
<form method="post" target="pagseguro" action="https://pagseguro.uol.com.br/v2/checkout/payment.html">
<!-- Campos obrigatórios -->
<input name="receiverEmail" type="hidden" value="[email protected]">
<input name="currency" type="hidden" value="BRL">
<!-- Itens do pagamento (ao menos um item é obrigatório) -->
<input name="itemId1" type="hidden" value="001">
<input name="itemDescription1" type="hidden" value="EloJob">
<input name="itemAmount1" type="hidden" value = "100.00">
<input name="itemQuantity1" type="hidden" value="10">
<input name="itemWeight1" type="hidden" value="0">
<!-- Código de referência do pagamento no seu sistema (opcional) -->
<input name="reference" type="hidden" value="REF1234">
<!-- Dados do comprador (opcionais) -->
<input name="senderName" type="hidden" value="José Comprador">
<input name="senderAreaCode" type="hidden" value="11">
<input name="senderPhone" type="hidden" value="56273440">
<input name="senderEmail" type="hidden" value="[email protected]">
<!-- submit do form (obrigatório) -->
<input alt="Pague com PagSeguro" name="submit" type="image" src="https://p.simg.uol.com.br/out/pagseguro/i/botoes/pagamentos/120x53-pagar.gif"/>
</form>
<script type="text/javascript">
var randu = 20.00;
document.getElementById("10").value = randu;
</script>
What do you want to do with
document.getElementById("10").value = randu;
?– Sergio
change the value of the 10.00 located in :
<input name="itemQuantity1" type="hidden" value="10.00">
– Thomas Reolon
Did you delete the other question? When so, just edit the current one instead of creating another one.
– user28595
And you want to change when? Why don’t you put that value in HTML directly? Where does it come from
20.00;
invar randu = 20.00;
? this is compiled on the server?– Sergio
yes comes from randu = 20.00 I edited if you can read again not the code the post.
– Thomas Reolon
Have you tested
document.querySelector('input[name="itemQuantity1"]').value = randu;
? I don’t understand where yours comes from10
here:getElementById("10")
– Sergio
No, I’ll try now.
– Thomas Reolon
I got sergiooooooo, Thank you very much it was worth just waiting 40 minutes after you delete my post kkk, and because I could not put the code, thank you Ucas <3
– Thomas Reolon
where I place as resolved?
– Thomas Reolon
and here: <script type="text/javascript"> Document.querySelector('input[name="itemAmount1"]'). value = 200.00; </script> <! -- This is the script-->
– Thomas Reolon
know why you’re not giving?
– Thomas Reolon
I gave an answer, take a look. If it solves your problem you can mark as accepted.
– Sergio
aaa gave yes agr q li I put 'number' ('20.00')
– Thomas Reolon
Is there any way I could put it like this?: randu = 20 <script type="text/javascript"> Document.querySelector('input[name="itemAmoun1"]'). value = randu+'. 00'; </script> <! -- This is the script--> ?
– Thomas Reolon
In that case you do so:
document.querySelector('input[name="itemAmoun1"]').value = randu.toFixed(2);
– Sergio