I want my clients to fill in a number in ethers instead of Wei (as I don't what them to go through the hassle of putting 18 zeroes in every time.)
I'm trying to do this in the following way in JavaScript, but for some reason, it triggers the transaction, but translates the amount 1-1 into wei (so input 1 gives 1 wei instead of 1000000000000000000 wei.)
$("#BetalenRekeningMI").click(function() {
contractMI.testmultiinput(web3.toWei($("#bedrag").val(), 'ether'),
$("#addressMI").val(), {value: 0},
function(err, result) {
console.log(err, result);
})
});
Here some more details. This is the corresponding HTML (without the comment tags of course:
<tr>
<td>
<input type="text" name="bedrag" id="bedrag" placeholder="Bedrag in Ether"/>
<input type="text" name="addressMI" id="addressMI" placeholder="Adres van de leverancier"/>
<button id="BetalenRekeningMI">Klik hier om te betalen</button>
</td>
</tr>
This is the Solidity function that the JS triggers:
function testmultiinput(uint256 bedrag, address klant) payable{
klant.transfer(bedrag);
}
contractMI.testmultiinput("1000000000000000000", 0xDEAD)
giving you the expected result? After entering 1 into the HTML Input, doesweb3.toWei($("#bedrag").val(), 'ether') == "1000000000000000000"
return true?web3.version.api
andweb3.version.node
; also check that there is no other code on the page that could alter the value of$("#bedrag")
; edit your question with the results