Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What's wrong with this statement: 2

Status
Not open for further replies.

GUJUm0deL

Programmer
Jan 16, 2001
3,676
0
0
US
What's wrong with this statement:

function one() {
var take = document.form1.textfield2.value;
if(document.form1.textfield.value == "x") {
take == "y";
}
}

This is supposed to see if the value of "textfield" is x, if it is then make the value of "textfield2" y...
Thanks for the help...:) I have not failed; I merely found 100,000 different ways of not succeding...
 
The function should read (changes in bold):

[tt]
function one() {
var take = document.form1.textfield2;
if(take.value == "x") {
take.value == "y";
}
}
[/tt]

Paul Ellis
[hammer] I've been programming since you had to punch holes in cards to code. (Always remember, number your cards!)
 
== is comparison, = is assignment, so your statement should look like this:

function one() {
if(document.form1.textfield2.value == "x") {
document.form1.textfield2.value = "y";
}
}
 
DOH! [flush] Yup, she's right. Got in a hurry coding. Bad, very bad. Picture me banging my head against the wall. Good catch Juanita! [thumbsup2] Paul Ellis
[hammer] I've been programming since you had to punch holes in cards to code. (Always remember, number your cards!)
 
Thanks guys (and gals, [smile])...
Pellis, don't feel bad, I made the same mistake with the "==" and "="...
We live, we learn... I have not failed; I merely found 100,000 different ways of not succeding...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top