hisoka Posted February 19, 2015 Share Posted February 19, 2015 I noticed that the value of this variable is without a double quotes: var participator_input = document.firstname.participator.value ; why is the value of the variable participator_input without double quotes??? Link to comment Share on other sites More sharing options...
justsomeguy Posted February 19, 2015 Share Posted February 19, 2015 Because the value of the variable is not "document.firstname.participator.value", the value is the result of that expression.You don't even need double quotes for scalar values though, e.g.: var val = 10;No quotes needed. You might do something like this also: var val = get_value();You don't want the value to be the text "get_value()", you want it to be the result of that.The only thing you quote is a string. A string in any context needs to be quoted. Anything that is not a string is not quoted. 1 Link to comment Share on other sites More sharing options...
hisoka Posted February 19, 2015 Author Share Posted February 19, 2015 "Because the value of the variable is not "document.firstname.participator.value", the value is the result of that expression." You mean that the value of the variable var participator_input can be any firstname inputed by a participator ? is this what you mean? if this what you mean then why do not we use an empty string instead of document.firstname.participator.value then return a value , which is the participator firstname and which will assigned to the variablevar participator_inputlike this : var participator_input = " " ; what is the difference between this var participator_input = " " ; and this var participator_input = document.firstname.participator.value ; ?? Link to comment Share on other sites More sharing options...
thescientist Posted February 19, 2015 Share Posted February 19, 2015 is an empty string is a string with a space is whatever the value of document.firstname.participator.value is at the time the script is executed (represented as a string) Link to comment Share on other sites More sharing options...
hisoka Posted February 19, 2015 Author Share Posted February 19, 2015 You did not reply to this if this what you mean then why do not we use an empty string instead of document.firstname.participator.value then return a value , which is the participator firstname and which will assigned to the variablevar participator_inputlike this : var participator_input = " " ; I did not ask what is var participator_input = " " ; I asked , in our context , what is the difference between this var participator_input = document.firstname.participator.value and this var participator_input = " " ; as both take any value the participator will input when the script is executed Link to comment Share on other sites More sharing options...
justsomeguy Posted February 19, 2015 Share Posted February 19, 2015 You mean that the value of the variable var participator_input can be any firstname inputed by a participator ? is this what you mean?The semantic meaning of the expression doesn't matter, what matters is that it gets the value on the right side of the = sign by evaluating that expression, and it uses that value for the variable on the left side of the = sign.what is the difference between thisvar participator_input = " " ;and thisvar participator_input = document.firstname.participator.value ;The first one assigns a single space character to the variable, the second one assigns the value of whatever that expression evaluates to.as both take any value the participator will input when the script is executedYou haven't shown a complete script, you're just asking what the difference is between 2 arbitrary lines. 1 Link to comment Share on other sites More sharing options...
hisoka Posted February 19, 2015 Author Share Posted February 19, 2015 thank you Link to comment Share on other sites More sharing options...
hisoka Posted February 19, 2015 Author Share Posted February 19, 2015 (edited) I have a doubt concerning my understanding to this piece of script function sum() { document.write(function check(document.firstname.participator.value )) ? "it all right" : "the firstname is wrong" ; } does it mean that if the value that evaluates the expression document.firstname.participator.value , when javascript is executed, is true then echo "it is all right" otherwise or else echo "firstname is wrong" ??????? Edited February 19, 2015 by hisoka Link to comment Share on other sites More sharing options...
Ingolme Posted February 19, 2015 Share Posted February 19, 2015 Using the function keyword there will cause an error. Press F12 to open developer tools and see any errors your code is having. You don't seem to understand functions, read about how to create and call functions here: http://www.w3schools.com/js/js_functions.asp 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now