What's wrong with this code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's wrong with this code

<!DOCTYPE> <html> <head> <title>Forms</title> </head> <body> <form action ="http :// www.sololearn.com"></form> <form> <input type="text" name="username" /><br /> <input type="password" name="password" /><br /> <input type="radio" name="gender" value="male"/> Male <br /> <input type="radio" name="gender" value="female"/> Female <br /> <input type="submit" value="submit"/> </form> </body> </html>

17th Jun 2021, 2:56 PM
Terminator 2.0
Terminator 2.0 - avatar
8 Answers
+ 1
Hi, Terminator 2.0: I think the problem is that you write <form> two times. I think it's: (from <body>) <body> <form action ="..."> <input> <input> <input> <input> <input> </form> </body> </html> I hope that's useful!
17th Jun 2021, 3:03 PM
HNL
HNL - avatar
+ 1
Hi❤️ At all using multiple form tag its ok but in your case is a bad practice and you was able to use just one : <form action="...." method=" ......"> <input type="....."> <input type="....."> <input type="....."> </form>
17th Jun 2021, 3:26 PM
CyrusKabir
CyrusKabir - avatar
0
Terminator 2.0 I already advised you to indent your code for improving readability ;P you could have many <form> elements in a page, but they cannot be nested, and they are required to be closed (have a closing tag) ^^ with good indentation you have could better identify your problem: you start a <form> element with 'action' attribute defined and you close it just after (empty form), then you start a new <form>, without attributes, wich you populate with <input>s... technically your code is valid, but will never send its values to any 'action' target url (at least without javascript) ;)
17th Jun 2021, 6:42 PM
visph
visph - avatar
0
<!DOCTYPE> <html> <head> <title>Forms</title> </head> <body> <form action ="http :// www.youtube.com" method="GET"> <label form="fname">First Name</label><br /> <input type="text" id="fname" name="fname" value="Unknown"><br> <label form="lname">Last Name</label><br /> <input type="text" id="lname" name="lname" value="08"><br><br> <input type="submit" value="submit"> </form> The code isn't working
18th Jun 2021, 12:06 AM
Terminator 2.0
Terminator 2.0 - avatar
0
Terminator 2.0 is it to hard for you to add indentation? except that your code miss closing tags 'body' and 'html' (this should be corrected by browers), you url in 'action' attribute has two unexpected spaces: one after 'http' and one before 'www' ^^ with that corrected (and indentation added), here's your now working code: https://code.sololearn.com/W4C52093OQy1/?ref=app (however, in sololearn app it will not open the response page in the app', but either open the youtube application or the youtube site in your browser ;P
18th Jun 2021, 12:18 AM
visph
visph - avatar
0
Tq so much
18th Jun 2021, 12:22 AM
Terminator 2.0
Terminator 2.0 - avatar
0
Https:// no space
19th Jun 2021, 4:14 AM
Riwaj adhikari
- 2
I think the problem is that you put ,<head> before <body>
19th Jun 2021, 6:39 AM
Victor Mwangi
Victor Mwangi - avatar