[SOLVED] Problem with form validation and display of elements in a code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

[SOLVED] Problem with form validation and display of elements in a code

When I press submit button in this code, I am automatically redirected to my browser's home page. It only happens on code playground. Also, the submit button works fine when I submit an option for the first time, but when I select another option and press the submit button, both the divs become displayed. I want only 1 div to be displayed in the latter case. Here is the code: https://code.sololearn.com/W9m4eldwe6cC/?ref=app Any working solution will be appreciated.

12th Feb 2018, 11:33 AM
DAB
DAB - avatar
2 Answers
+ 5
Great work with tables! In line 16 (HTML), you should write onsubmit='showData(); return false;' In showData function, if(s == 'HTML') add -> $("#JavaScript").css("display","none"); next, if(s == 'JavaScript') add -> $("#HTML").css("display","none"); This is done because display: hidden; property not always work with table elements
12th Feb 2018, 2:20 PM
777
777 - avatar
+ 5
Problem solved. Thanks @Blue 😃
12th Feb 2018, 3:50 PM
DAB
DAB - avatar