if then else in javascript

  • Thread starter bjornhenrikformo
  • Start date
B

bjornhenrikformo

I am a totally newbie in javascript...

I want to do the following with a script which can be regarded as a
windows logon-script:

If WindowsUsername_starts_with_the_letters "ABC" then
'do som stuff
else
'do something else
end if

Anybody know how to do this - the syntax of the if - then - else -
endif & how to match the first 3 letters of a windows username with a
given 3 letters "ABC" (case insensitiv)?

Will be appreciated!
 
E

Evertjan.

wrote on 05 okt 2006 in comp.lang.javascript:
I am a totally newbie in javascript...

I want to do the following with a script which can be regarded as a
windows logon-script:

If WindowsUsername_starts_with_the_letters "ABC" then
'do som stuff
else
'do something else
end if

Anybody know how to do this - the syntax of the if - then - else -
endif

if (boolean) {dothis();} else {dothat();};

That is the basics, did you read the NG faqs?

<http://www.jibbering.com/faq/>
& how to match the first 3 letters of a windows username with a
given 3 letters "ABC" (case insensitiv)?

You can find that all there.
 
T

Tim Slattery

I am a totally newbie in javascript...

I want to do the following with a script which can be regarded as a
windows logon-script:

If WindowsUsername_starts_with_the_letters "ABC" then
'do som stuff
else
'do something else
end if

Anybody know how to do this - the syntax of the if - then - else -
endif & how to match the first 3 letters of a windows username with a
given 3 letters "ABC" (case insensitiv)?

I don't know how to get the Windows username, but other than that...

re = /^abc/i;
if (WindowsUsername.match(re))
{
//do come stuff
}
else
{
//do something else
}

re is a Regular Expression object. It describes a string where the
first three characters are "abc" in any case.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Thu,
5 Oct 2006 09:01:32 remote, seen in Tim
Slattery said:
re = /^abc/i;
if (WindowsUsername.match(re))
{
//do come stuff
}
else
{
//do something else
}

Since the complex result of successful .match() is not needed,

if (/^ABC/i.test(WindowsUsername))
{
// do some stuff
}
else
{
// do something else
}

Are FIPS respected by .gov users?
 

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

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,277
Latest member
VytoKetoReview

Latest Threads

Top