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

if then else in javascript

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

Oct 5 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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/>
<http://www.merlyn.demon.co.uk/js-index.htm>
& 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.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Oct 5 '06 #2

P: n/a
bj**************@gmail.com wrote:
>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.

--
Tim Slattery
Sl********@bls.gov
Oct 5 '06 #3

P: n/a
Tim Slattery <Sl********@bls.govwrote in
news:l6********************************@4ax.com:
I don't know how to get the Windows username, but other than that...
Not possible via javascript.
Oct 5 '06 #4

P: n/a

Good Man wrote:
Tim Slattery <Sl********@bls.govwrote in
news:l6********************************@4ax.com:
I don't know how to get the Windows username, but other than that...

Not possible via javascript.
var username = prompt('Please enter your username');

:-)
--
Rob

Oct 5 '06 #5

P: n/a
JRS: In article <l6********************************@4ax.com>, dated Thu,
5 Oct 2006 09:01:32 remote, seen in news:comp.lang.javascript, Tim
Slattery <Sl********@bls.govposted :
>
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?

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Oct 5 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.