Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Simple javascript problem
Old 05-23-2009, 01:28 PM Simple javascript problem
Junior Talker

Posts: 1
Name: Weedave
Trades: 0
hey yesterday i decided to learn jaascript and at the moment i have a button tat when u press it it will tel u iff you are lucky or not, it also asks for your name...well thats what its ment to do atm nothing hapens when u press the button here is the coding i have atm.

Code:
<html>
<head>
<script type ="text/javascript">
function luck();
{
//asks to enter name,
var name=prompt("Please enter your name","Harry Potter");
if (name!=null && name!="")
{
/*works out random number if more than 0.5 then
*/the person is lucky then displays results
var r=Math.random();
if(r>0.5)
 {
 document.write("lucky");
 }
else 
 {
 document.write("unlucky")
 }
}
}
</script>
</head>
<body>
<form>
//button that redirects to the top function
<input type="button" value="Click here to see how lucky you are =D" onclick="luck()" />
</form>
</body>
</html>
im sure its simple im just not seeing it
Weedave is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-26-2009, 05:58 AM Re: Simple javascript problem
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
Ok, there are a few problems;
first:
Code:
function luck();
the semi-colon means the function is over, change it
Code:
function luck()
Next, your comments are broken:
Code:
/*works out random number if more than 0.5 then
*/the person is lucky then displays results
Change it so, all of the comment is commented:
Code:
/*works out random number if more than 0.5 then
  the person is lucky then displays results
*/
__________________

Please login or register to view this content. Registration is FREE

willcode4beer is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Simple javascript problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09725 seconds with 12 queries