HTML form/textarea data | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

HTML form/textarea data

how can I take the data put into a form or textarea and utilize that data? for example, if i wanted to make sure they typed blue and not red. https://code.sololearn.com/WViV8wp6Ntyt/?ref=app

28th May 2019, 11:03 PM
koala 🐨
koala 🐨 - avatar
7 Answers
+ 2
Oh cool Thanks for adding code for clarity 👍 Well, there's just one tiny issue here, you were reading the innerHTML attribute rather than value, if you read the value attribute you'll get it right. if (document.getElementById("cmd").value === "$cmd") There, try it like that, that's how I got it working.
28th May 2019, 11:43 PM
Ipang
+ 2
a form does take input. if it ask for "first name" for example, as many examples do, it requires input. Also, ive tried that and it doesnt work. When a site like Google asks for your username, how does it read what you wrote?
28th May 2019, 11:25 PM
koala 🐨
koala 🐨 - avatar
+ 2
done 😁 cmd simulator lol
28th May 2019, 11:36 PM
koala 🐨
koala 🐨 - avatar
+ 2
it worked, thank you so much for your help
28th May 2019, 11:46 PM
koala 🐨
koala 🐨 - avatar
+ 2
You're welcome! alright, good luck with that simulator 👍
28th May 2019, 11:54 PM
Ipang
+ 1
I guess you can specify Id attribute for the textarea then use document.getElementById() function to obtain its value attribute when you need it. Once you have the value you can compare it with "blue" and see if they match. I don't understand what you mean by "data put into a form", as I understand it, form doesn't take input (I could be wrong).
28th May 2019, 11:23 PM
Ipang
0
I'm not sure how Google does it, as it is a tech giant it must be using some advanced techniques for it's sites. Can you attach your code link on Description section of your original question (above)?
28th May 2019, 11:32 PM
Ipang