Jump to content

hisoka

Recommended Posts

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.
  • Like 1
Link to comment
Share on other sites

"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

  1. is an empty string
  2. is a string with a space
  3. 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

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

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 executed

You haven't shown a complete script, you're just asking what the difference is between 2 arbitrary lines.
  • Like 1
Link to comment
Share on other sites

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 by hisoka
Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...