51 Replies
at this point, i think this is more about trying to understand mdn rather than forms
like im genuinely curious
wait let me share some things written in it
What’s your code look like? What isn’t working? What do you think it should be doing?
i didnt even understand what i have to write💀
take a look at this
this is the first instruction given in the mdn about the form element
like, this is just theoretical knowledge about the different attributes of form
what do i do now
in w3 school, the instructions were more practical
and straight to the point
that's the very very technical part of it
those are the attributes that the element accepts
how do i even know which ones to use😭
MDN Web Docs
<form>: The Form element - HTML: HyperText Markup Language | MDN
The <form> HTML element represents a document section containing interactive controls for submitting information.
well, easy:
- use the global ones when you need
- don't use the deprecated ones
- use the ones that do what you want to do or that help you get there
i think im approaching mdn in a wrong way
what are you even trying to do?
im seeing it as a go-to website for learning webdev
since i assumed that thats what people suggested me to do
im not sure if thats what they told me
dude
what are you trying to do?
where's the code?
what's wrong with it?
im trying to learn about forms
same as yesterday
what for?
and did you ever write any code yet?
i don't see a form there
after doing this, i thought to redo it using form and <template>
and thats why today i thought to learn about forms
and couldnt understand anything
alright
what do you want to do with the form?
but when i use youtube or any other website to learn about forms, i understand
the same thing that i did in the codepen, since forms are the correct way to do it
u told me
no no
tell me
what are you trying to do?
i want you to think about it
it doesn't matter how much you read and study about it if you don't know wtf you will do
i want to be able to work with forms through javascript
reading the input value etc
okay, did you checked the examples?
yeah
did you understand anything?
it was html/css only
yeah
then start from there
make a form out of it
forget javascript for now
isnt this it
almost
and adding the action attribute in the form
you usually do need that, yes
your button also needs the type
in the example, they dont show it
because the default is
submit
but you should be explicit about everythingohk
is web.dev a good source to learn
it seems so much easier
never used that
Not bad, but seems to focus a lot on Python. And from listening to their podcast they’re not front end people so any FE content needs to be seen with some skepticism
what did u use as a beginner to learn web dev
stackoverflow, when it was good
trial and error
then mdn
Let’s keep this thread on-topic please
If you want to discuss learning platforms check #resources or make a discussion post
actually the intent for this post was both
should i change the topic
is it fine
One post, one question
https://codepen.io/Designer-the-encoder/pen/gbbyjBb
to integrate form into this project, it seems that i only had to change to div element to form element
because the js seems to remain the same, do i need to change anything
instead of grabbing the elements manually, you can use a formdata
also, you have to listen to the submit event, not the click
ohk
In order for there to be a form submit event there needs to be a form element. And there's not
oh wait thats the outdated code
Hopefully this minimal example will show you how forms work
omggggg thanks
when we dont use " event.preventDefault();" on forms addeventlistener, the page reloads the moment we click submit
so it means that its always a necessity to use it on forms, right?
are there any cases where we dont use " event.preventDefault();"
The default is for the form to redirect navigate to a new page. If you don't want that you need to prevent the default from happening
not redirect: navigate.
redirects are different and function differently, and may or may not lose the submitted form data
i know im being annoying with my correction, but both are indeed different
as the name of the method suggests, it cancels the default action that would have happened otherwise
for example, on a link it would have been to navigate to a new page or on a file input would be to show the file selection
usually, you dont use that method on click, change, input, search and resize events
there are more events
ohh
so whether we use " event.preventDefault(); " or not depends on the type of event?
It depends on if you want to let the default happen or not. It's not about the event, is about the outcome you want