Question:
Values out of TextBoxes JavaScript?
anonymous
2009-09-09 03:29:24 UTC
I have having trouble understanding why the code below does not work. I want to get the value, out a textbox, and pass it to the alert function. I have tried it two different ways but alert get undefined, as an argument why?


















First Name:
Last Name:







Four answers:
Megan
2009-09-09 03:45:06 UTC
You're making it much more complicated than it needs to be:























First Name:
Last Name:














~ Megan
bellato
2009-09-09 03:46:23 UTC
It is because your structure is incorrect. Don't place javascript amidst your html codes becasue they are not meant for displaying. It should be in between tag. Anyway, I make my own version. I did not use name attribute instead I use IDs. This is cool than name attribute. Code below: (It works!) Just copy paste.



____________________________________







































First Name:
Last Name:










cherida
2016-10-05 04:00:29 UTC
there is an significant question for me to ask formerly i'd desire to wager what the incorrect is with your website. Do you spot the style (positioned up) container "Hidden1" at server-area with a incorrect fee (in all probability the preliminary fee set to the hidden enter formerly JavaScript changed it), or you do no longer see the hidden enter “Hidden1” in any respect (it particularly is, once you look on the style variables at server-area, there is not any such variable as "Hidden1")? the respond on your question relies upon in this commentary. Please circulate away me one greater remark on the tip of your question so as that i'd desire to wager what the incorrect is.
zeex
2009-09-09 06:33:50 UTC
dont use single quote in validate function such as:



wrong:

validate( ' + document.submission.firstName.value + ' );"

validate(' + x + ');"



Currect:

validate(document.submission.firstName.value);"

validate(x);"


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...