Reputation: 11
It's HTML Code:
<tr>
<td class="caption">Amount</td>
<td><input type="text" name="Amount" value="" size="30" id="Amount"
onkeypress="return isNumberKey(event);" onchange="this.value =
changeAmount(this.value);" maxlength="18"></td>
</tr>
<tr>
<td>Amount Word</td>
<td><textarea name="AmountWord" cols="" rows="" wrap="soft"
class="text_sotien" id="AmountWord" readonly=""></textarea></td>
</tr>
My website will have 2 field as above. changeAmount() function is a script on my server. Now, I wanna create a Javascript script for my customer. When they pasted it on your browser console (Ctrl + Shilf + I on Chrome or F12 on Firefog), it will fill new value of Amount field then call function changeAmount() to change value of AmountWord. It's my code but it only can change value of Amount field, not call changeAmount() function to change value of AmountWord field :(
javascript:document.getElementById("Amount").value='111000';document.getElementById("AmountWord").focus; document.getElementById("AmountWord").click();
Please help me
Upvotes: 1
Views: 4900
Reputation: 9165
With modern browser methods:
const input = document.querySelector("input[name='Amount']")
input.dispatchEvent(new CustomEvent("change"))
Better to just avoid inline JS calls like that though.
Upvotes: 2