if.. else if sentence

O

Obscurr

hi,
I got a problem with a standard if... else if sentence. Each one works
alone, (ie. putting a /*..*/ around one of the conditions)but by
combining them, only the first one triggers. The code :

function sjekk()
{
if (window.document.info.organisasjon.value =='')
{
alert('hey!');
return(false);
}
else {
if (window.document.info.check_feste.checked == false)
{
var answer = confirm('Continue?');
if (answer) {
return (true);
}
else {
return(false);
}
}
}
}

obscurr
 
E

Erwin Moller

Obscurr said:
hi,
I got a problem with a standard if... else if sentence. Each one works
alone, (ie. putting a /*..*/ around one of the conditions)but by
combining them, only the first one triggers. The code :

function sjekk()
{
if (window.document.info.organisasjon.value =='')
{
alert('hey!');
return(false);
}
else {
if (window.document.info.check_feste.checked == false)
{
var answer = confirm('Continue?');
if (answer) {
return (true);
}
else {
return(false);
}
}
}
}

obscurr



Use alert("I am here!") in different places and see if the satement is
reached.
It is the very old timers approach, but always works.

If a certain line is not reached allthough you expected it to be reached,
you know where to start debugging.

Hope that helps.

Regards,
Erwin
 
L

Lee

Obscurr said:
hi,
I got a problem with a standard if... else if sentence. Each one works
alone, (ie. putting a /*..*/ around one of the conditions)but by
combining them, only the first one triggers. The code :

This doesn't address your problem directly, but it might
help if you simplify your code:
if (window.document.info.check_feste.checked == false)
{
var answer = confirm('Continue?');
if (answer) {
return (true);
}
else {
return(false);
}
}

can be written as:

if (!window.document.info.check_feste.checked)
{
return(confirm('Continue?'));
}
 
W

W d'Anjos

In the original code if "window.document.info.organisasjon.value !=
''" and "window.document.info.check_feste.checked == true" nothing is
returned.

Try:

function sjekk()
{
var answer = false;
if (window.document.info.organisasjon.value =='')
{
alert('hey!');
}
else
{
if (window.document.info.check_feste.checked == false)
{
answer = confirm('Continue?');
}
}

return answer;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top