473,505 Members | 15,212 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

if.. else if sentence

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
3 8494
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2061
by: Sidhu | last post by:
Hoe to relplace the word in sentence? Can any one send program?
6
1950
by: mike | last post by:
Hello, I am trying to write some code to parse a sentence and hyperlink just the words in it. I used Aaron's code from an earlier question as a start. So far, all the code does below is...
8
2473
by: Scott | last post by:
I would like to automatically change the first letter to upper case and keep the rest intact of each sentence on a control of a form, i.e., i am going to school. see you in the afternoon. -I am...
3
5588
by: dalearyous | last post by:
ok basically i need to write a program that will replace normal words in a sentence with pirate words. the trick is it needs to be able to take two word phrases. i went about this two different ways:...
12
3959
by: jackson.rayne | last post by:
Hello, I am a javascript newbie and I'm stick at one place. I have a requirement where I will get a sentence in a variable example var v1 ="This is a sentence"
3
5028
by: dmalhotr2001 | last post by:
Hi, For string extraction function in vb, if I feed in a paragraph, how do I extract the first sentence of that paragraph. Thanks :D
19
66187
by: fellya | last post by:
Hi, i don't have enough experience in writing codes in Python but now i'm trying to see how i can start using Python. I've tried to write a simple program that can display a sentence. now my...
1
4327
by: fellya | last post by:
Hi, i don't have enough experience in writing codes in Python but now i'm trying to see how i can start using Python. I've tried to write a simple program that can display a sentence. now my...
4
3687
by: xhani | last post by:
Hi , can anyone help me about writing a given sentence in Floyd's triangle . e.g , printf("Write a sentence:\n"); sentence=getchar(); ( I should not use arrays ,...
0
7216
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7303
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5613
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.