Click to See Complete Forum and Search --> : Looping name thing


idiotsoftcorp
12-12-2003, 07:12 PM
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?");
}

fredmv
12-12-2003, 07:23 PM
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>

idiotsoftcorp
12-14-2003, 05:36 PM
THANK YOU!!! What is this CDATA junk????

fredmv
12-14-2003, 05:40 PM
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.