473,387 Members | 1,687 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Checking the returned value of a prompt()

Death Slaught
1,137 1GB
this is my code uhhh it doesnt work so what am i doing wrong here?

[HTML]<html>
<head>
<script type="text/javascript">
var name1;
name1=prompt("Hi what's your name?","defaultvalue");

if (name1 == user1)
{
document.write("<b>Hello user1</b>")
}
else (name1 == user2)
{
document.write("<b>Hello user2</b>")
}
</script>
</head>
</html>[/HTML]


Thanks, Death Slaught
Aug 13 '07 #1
4 1176
pbmods
5,821 Expert 4TB
Heya, Death.

Try putting user1 and user2 in quotes in your conditionals. Right now, JavaScript is looking for variables named user1 and user2.

PS. Changed thread title to better describe a problem (threads tend to get more responses when the title contains nouns *and* verbs, with emphasis on plural).
Aug 13 '07 #2
Death Slaught
1,137 1GB
Heya, Death.

Try putting user1 and user2 in quotes in your conditionals. Right now, JavaScript is looking for variables named user1 and user2.

PS. Changed thread title to better describe a problem (threads tend to get more responses when the title contains nouns *and* verbs, with emphasis on plural).
thanks but the same thing happens as when i changed it to numbers when i enter user 1 it write hell user1helluser2 and every thing else including when i enter user2 says hello user2

Thanks, Death Slaught
Aug 13 '07 #3
pbmods
5,821 Expert 4TB
Heya, Death.

Expand|Select|Wrap|Line Numbers
  1. document.write("<b>Hello " + user1 + "</b>");
  2.  
Aug 13 '07 #4
pbmods
5,821 Expert 4TB
Heya, Death.

Something like this, then?

Expand|Select|Wrap|Line Numbers
  1. if (name1 == user1)
  2. {
  3.     document.write("<b>Hello " + user1 + "</b>");
  4. }
  5.  
Aug 13 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Randell D. | last post by:
Folks, I have a form called "ourTestForm". Its a test form - nothing special - it contains five input tags - they are named one, two, three, four and five. The input tags are of type...
30
by: Michael B Allen | last post by:
I have a general purpose library that has a lot of checks for bad input parameters like: void * linkedlist_get(struct linkedlist *l, unsigned int idx) { if (l == NULL) { errno = EINVAL;...
99
by: Mikhail Teterin | last post by:
Hello! Consider the following simple accessor function: typedef struct { int i; char name; } MY_TYPE; const char *
3
by: Moe Sizlak | last post by:
Hi, Can I check a checkbox by default based on the value returned from a database? for example if the value (dr("frm7value")) returned from a db field is "YES" how can I check the checkbox by...
6
by: Neil | last post by:
Hi, I have an aspx page with a number of web controls on it and one of these is a cancel button. I want to check the page to see if the user has changed any of the controls, i..e typed some text...
3
by: rcolby | last post by:
Hi all, I'm experiecing a problem with dates being returned from SQL 2000 Database. I retrieve the last updated field (Date) from a sql 2000 and then compare the returned date with another...
21
by: planetthoughtful | last post by:
Hi All, As always, my posts come with a 'Warning: Newbie lies ahead!' disclaimer... I'm wondering if it's possible, using raw_input(), to provide a 'default' value with the prompt? I would...
4
by: Tom Bradford | last post by:
Let me first say that I'm sure that this subject has come up before, and so forgive me for beating a dead horse. Secondly, let me say that Python's strength is its dynamic nature, and I don't...
10
by: Phil Latio | last post by:
I am inserting data into user table which contains 5 fields, sounds simple enough normally but 2 of the fields are designated as UNIQUE. If someone does enter a value which already exists, how do I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.