Link: https://glitch.com/edit/#!/thoughtbin?path=static%2Findex.html%3A87%3A138
Im trying to make an AES crypto thing for hastebin (thoughtbin.glitch.me) and the problem
is at lines 87 to 89. Textbox 1 has the content, Textbox 2 has the key, and the button after it encrypts it.
I’ve tried $(#id).val(‘content’), and myTextArea.innerHTML = ‘something’;
What exactly is your error?
Could you show us the errors in the console?
<button type="button" onclick="myTextArea.innerHTML = encrypt(document.getElementById('cont').value,document.getElementById('contkey'));">
AES It!
</button>
^ is lines 87 to 89.
I think the first thing you should do is try not to use inline onclick functions - it would be a better idea to make a JS DOM or jQuery selector and add event listeners - something like
var button = document.getElementsByTagName("button")[0]
button.addEventListeners("click", () => {
//encrypt, etc
})
Also because all of this is happening client side, change it to myTextArea.innerText
- I (think?) that it’s more secure.
When you get back on Glitch forums go ahead and add console errors/expected output and the such.
Use the value property of the textarea not innerHTML.
1 Like