Forum Moderators: open

Message Too Old, No Replies

Please help with a simple yet stupid javascript!

need help for lame script

         

haryanto

3:59 pm on Jan 8, 2004 (gmt 0)

10+ Year Member



Hi guys I need to do a little javascript here it is kinda stupid but here goes.

I am having a site for my family.
members of my family are : Steve,Melinda,Jessie and Roy.

I wanna do a javascipt to popup a window asking for name.
If the name entered is not any of the 4 names above, it will display 'You aren't part of da family.' on the webpage.

Yeah Iknow its lame and stupid but guess what it is actually my dad's idea!
Can anyone of you please help me?

Roy

TrinkDawg

5:52 pm on Jan 8, 2004 (gmt 0)

10+ Year Member



Hi Roy, try something like this:

<head>
...
<script language="JavaScript">
<!--
var userName = prompt("Give me your name: ","");
-->
</script>
...
</head>
<body>
...
<script language="JavaScript">
<!--
if ((userName!= 'Steve') && (userName!= 'Melinda') && (userName!= 'Jessie') && (userName!= 'Roy'))
{
document.write('You aren't part of da family.');
}
else
{
document.write('Welcome, ' + userName + '!');
}
-->
</script>
...
</body>

haryanto

12:32 am on Jan 9, 2004 (gmt 0)

10+ Year Member



Think Dawg,

I tried the script. It doesn't work. Whether or not I entered the right password theres nothing on the page and in addition theres a scripting error icon displayed in the left hand side of the status bar.

crxchaos

3:42 am on Jan 9, 2004 (gmt 0)

10+ Year Member



this line:

document.write('You aren't part of da family.');

should be modified to this:

document.write('You aren\'t part of da family.'); 

Also, the lines with the three periods in a row should be deleted.

moonbather

4:01 am on Jan 9, 2004 (gmt 0)

10+ Year Member




<body>
<script>
<!--
// moonbather
var yourname= prompt('Please enter your name:', ' ');
lcyourname=yourname.toLowerCase();
if ((lcyourname=='melinda') ¦¦ (lcyourname=='jessie'))
/* add the other names likewise */
document.write("<h1>Hello, " + yourname + ", and welcome! <\/h1>");
else document.write("<h1>Hey, Watcha doin\'! <br \/>You ain\'t parta da family! <\/h1>");
// -->
</script>