By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,574 Members | 1,459 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,574 IT Pros & Developers. It's quick & easy.

if.. else if sentence

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Obscurr wrote:
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
Jul 20 '05 #2

P: n/a
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?'));
}

Jul 20 '05 #3

P: n/a
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;
}

ob*****@hotmail.com (Obscurr) wrote in message news:<44*************************@posting.google.c om>...
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

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.