Welcome to WebmasterWorld Guest from 35.175.120.174

Forum Moderators: open

Message Too Old, No Replies

Please help with a simple yet stupid javascript!

need help for lame script

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

Junior Member

10+ Year Member

joined:June 24, 2002
posts:110
votes: 0


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

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

New User

10+ Year Member

joined:Dec 11, 2003
posts:20
votes: 0


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>

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

Junior Member

10+ Year Member

joined:June 24, 2002
posts:110
votes: 0


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.

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

New User

10+ Year Member

joined:Aug 24, 2003
posts:34
votes: 0


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.

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

Junior Member

10+ Year Member

joined:June 13, 2003
posts:44
votes: 0



<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>