/    Sign up×
Community /Pin to ProfileBookmark

Looping name thing

How do you make:
-Something that asks for your name, then confirms and if you click cancel it loops and asks for your name again?I tried this:

var name = prompt(“Type in your name!”,”your name here”);
while (confirm(“Is your name ” + name + “?”));
{alert(“Hello ” + name + “!”)
alert(“You were suprised when I knew yer name huh?”);
}

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@fredmvDec 13.2003 — Welcome to the forums.<script type="text/javascript">
//<![CDATA[
var n = prompt('Enter your name:', '');
while(!confirm('Is your name ' + n + '?')) n = prompt('Enter your name:', '');
alert('Hey ' + n + '.');
//]]>
</script>
Copy linkTweet thisAlerts:
@idiotsoftcorpauthorDec 14.2003 — THANK YOU!!! What is this CDATA junk????
Copy linkTweet thisAlerts:
@fredmvDec 14.2003 — You're very welcome. The CDATA XML block isn't needed unless you are using an XHTML DOCTYPE. Feel free to remove it if you aren't. It's there so when the page is validated, the SGML parser ignores all script contents which could result in parsing errors.
×

Success!

Help @idiotsoftcorp spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...