0

Why does the output for my code redirect when i try testing it?

Every time I try to test my code it always redirects. I do not know why this is happening. I welcome any suggestions. https://code.sololearn.com/W5UPF3jzMXPH

27th Jun 2017, 9:28 PM
Kevin Oudai
Kevin Oudai - avatar
6 Antworten
+ 4
for the button use: <input type="button" value="Encode/Decode" onclick="fixMessage()"/> that way the button won't submit the form and causing recursion in the page. Do not use innerHTML for textArea in the fixmessage function: element.innerHTML = (cipherText(elementValue) + "\nJEVGGRA OL XRIVA BHQNV."); Use value instead, like below: element.value = (cipherText(elementValue) + "\nJEVGGRA OL XRIVA BHQNV."); And the last one, please check your cipherText function... there is one small mistake... I'll let you find it by yourself...
28th Jun 2017, 3:16 AM
Youngky
+ 1
Without an "action" attribute, your form would submit to the current page, and hence the redirection. You could do a "return fixMessage();" within the onclick event, and add "return false;" to the end of the fixMessage function, to solve that problem.
27th Jun 2017, 10:15 PM
Alex
+ 1
You can take this alternative: * In the HTML side, instead of putting <input type ="submit" value = "Encode/Decode" onclick = "fixMessage()"/> you better replace the type "submit" by button, like <input type ="button" value = "Encode/Decode" onclick = "fixMessage()"/> on the button click, the function will still be called and executed. the rest is your own task
27th Jun 2017, 10:25 PM
BenjiSolo
BenjiSolo - avatar
0
Thank you it worked nicely.
27th Jun 2017, 10:27 PM
Kevin Oudai
Kevin Oudai - avatar
0
I have been getting the errors since earlier. It is not taking any values. It is only changing the default content. :) thanks
28th Jun 2017, 3:19 AM
Kevin Oudai
Kevin Oudai - avatar
0
okay it works as it should now..I also fix the brackets in the cipherText.
28th Jun 2017, 3:37 AM
Kevin Oudai
Kevin Oudai - avatar