Form attribute | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Form attribute

I am wondering, about the name and id attribute in the form element. We can have the name attribute with same value to the many element but id attribute value should be unique to each element. But this is not my doubt . My doubt is , When I have a forms like 1. <form name="myForm" onsubmit=return false></form> 2. <form name="myForm" id="newId" onsubmit=return false></form 3. <form name="myForm" id="myForm" onsubmit=return false></form From all the above forms if I fire the submit event in the document object like document.myForm.submit() This submit action will trigger if I give the form element like 3rd . Why 1st and 2nd is not working though it has myForm as a name attribute in it. Please help me to understand it better.

20th Jan 2024, 3:12 PM
Swetha
3 Answers
0
Code , I'm sorry I won't answer your HTML question in full (I'm too into Python these days), but I will point you to my favorite HTML reference, w3schools. The navigation is a little unexpected, but once you grok it, you'll find (almost) everything about HYML documented there. Here's the page on the <form> tag. https://www.w3schools.com/tags/tag_form.asp
20th Jan 2024, 7:36 PM
Rain
Rain - avatar
0
Thanks Rain for taking time to answer my question. But I don't think I can find the solution to my questions in w3school.
21st Jan 2024, 2:31 AM
Swetha
0
Code , But that page explains the <form> tag!
21st Jan 2024, 6:18 AM
Rain
Rain - avatar