What's New
Off Topix: Embrace the Unexpected in Every Discussion

Off Topix is a well established general discussion forum that originally opened to the public way back in 2009! We provide a laid back atmosphere and our members are down to earth. We have a ton of content and fresh stuff is constantly being added. We cover all sorts of topics, so there's bound to be something inside to pique your interest. We welcome anyone and everyone to register & become a member of our awesome community.

JS help

Blake

Dedicated Member
Member
Joined
Nov 10, 2009
Posts
318
OT Bucks
656
If any one is good with JS i need some help. This is my code:

PHP:
<script type=text/javascript>



var name=prompt(What is your name?);

alert(hello  +name+  how are you today?);



var answer=promt(How are you today? answer with good or bad only);

if(name1=good)

{

alert(Thats good to hear);

}

else(answer=bad)

{

alert(Aww, sorry to hear)

}

</script>



The problem is with this:

PHP:
var name=prompt(What is your name?);

alert(hello  +name+  how are you today?);

once i enter my name it should continue onto this line:

PHP:
var answer=promt(How are you today? answer with good or bad only);



But it doesn't the script ends, any ideas?



And for any of you who want to just try this out follow these steps.

Open notepad>copy and paste the code>save it with the extension .html>open a new tab in your broweser> got to file>open file> look for the file.
 
Always proof-read.

Here's your code back
smile.png


PHP:
<script type=text/javascript>



var name=prompt(What is your name?);

//alert(hello  +name+  how are you today?);

var fool=0;

while(fool==0){

var answer=prompt(Hello  +name+, how are you today? Answer with good or bad only.);

if(answer==good)

{

alert(Thats good to hear);

fool=1;

}

else if(answer==bad)

{

alert(Aww, sorry to hear)

fool=1;

}

else

{

alert(Please try again.);

}

}

</script>
 
Back
Top Bottom