|
-
Jan 11th, 2006, 09:44 PM
#1
Thread Starter
Addicted Member
Multiple If statements
Hey everyone I need a little help again I am rewriting my calculator program and am having problems with my code...
VB Code:
function disp_prompt()
{
var i= document.getElementById("investment").value;
var r= document.getElementById("reinvest").value;
r=r - 0;
i=i - 0;
c=0+1
s=0
s1=100
s2=1000
s3=10000
q=100
q2=200
q3=300
total=0
if (i>s && i<s1);
if (c=1)<----- I cant get JS to recognize this code it just passes over it... or just doesnt do anything
{
total=i + i * q / 100
for (i=2;i<=r;i++)
total=total + total * q / 100
document.getElementById("profit").value= "$" +total 'but if i add a "+ c" it will add the number...
}
else
{
total=1000009
document.getElementById("profit").value= "$" +total
}
}
What am I doing wrong????
Last edited by messup000; Jan 12th, 2006 at 12:26 AM.
-
Jan 11th, 2006, 10:11 PM
#2
-
Jan 11th, 2006, 10:27 PM
#3
Thread Starter
Addicted Member
Re: Multiple If statements
if i>0 and if i<100
watch window? you mean like the vbcode window
-
Jan 11th, 2006, 10:41 PM
#4
Thread Starter
Addicted Member
Re: Multiple If statements
well i ended up using c<0 or c>0 instead... it seemed to work so thx for the help anyway...
-
Dec 25th, 2006, 04:23 AM
#5
Member
Re: Multiple If statements
if (i>s && i<s1);
Do not contain ";" behind if statement
Missing "{", so code is terminated!
-
Dec 26th, 2006, 07:27 AM
#6
Re: Multiple If statements
 Originally Posted by messup000
Hey everyone I need a little help again  I am rewriting my calculator program and am having problems with my code...
VB Code:
function disp_prompt()
{
var i= document.getElementById("investment").value;
var r= document.getElementById("reinvest").value;
r=r - 0;
i=i - 0;
c=0+1
s=0
s1=100
s2=1000
s3=10000
q=100
q2=200
q3=300
total=0
if (i>s && i<s1);
if (c=1)<----- I cant get JS to recognize this code it just passes over it... or just doesnt do anything
{
total=i + i * q / 100
for (i=2;i<=r;i++)
total=total + total * q / 100
document.getElementById("profit").value= "$" +total 'but if i add a "+ c" it will add the number...
}
else
{
total=1000009
document.getElementById("profit").value= "$" +total
}
}
What am I doing wrong????
c=1 <-- will assign the value of 1 to c and take the left most side of the expression after assignment as the vlaue (1). Hence it will always evaluate to true.
Instead of using the assignment operator =, you should use the equality operator ==
if (c == 1)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|