Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prompt for Name Script Curious question... don't know if it's possible

Status
Not open for further replies.

TonyU

Technical User
Feb 14, 2001
1,317
US
[tt]
Hello all JS gurus, let me just say this &quot;I know <%$#@*/> about JavaScript but I can troubleshoot it to death X-)

Shooting in the dark here....

Is it possible to use this script

<script>
var name=prompt(&quot;Please enter your name&quot;,&quot;&quot;)
</script>

You typed:
<script>document.write(name);</script>

and modify it such way to make the prompt ask three specific questions
and ONLY if on the first answer the user typed something like red (or a specific answer)
the other prompts will not display?


I know, don't kill me, I'm just wondering...








T ® Ñ ¥
To keep a lamp burning we have to keep puting oil in it.
logo.gif

 
brute force approach... so it stinks but should give you some ideas
Code:
<script>
var name=prompt(&quot;Please enter your name&quot;,&quot;&quot;)
var cell = &quot;&quot;;
var email = &quot;&quot;;
if( name.indexOf(&quot;tony&quot;) == 0){
	cell = prompt(&quot;enter your cell phone&quot;,&quot;&quot;);
	if( cell.length >= 7){
		email = prompt(&quot;enter your email&quot;,&quot;&quot;);
		// whatever
	}else
		alert(&quot;That's just not right...&quot;);
}else
	alert(&quot;Your supposed to be tony you bonehead!&quot;);
</script>

-pete

 
[tt]
[lol]
I'll try it and let you know. Thanks as always palbano


T ® Ñ ¥
To keep a lamp burning we have to keep puting oil in it.
logo.gif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top