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
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...
+ 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.
+ 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
0
Thank you it worked nicely.
0
I have been getting the errors since earlier. It is not taking any values. It is only changing the default content. :) thanks
0
okay it works as it should now..I also fix the brackets in the cipherText.