I'm learning javascript and Im working on a text game. The do while loop isnt working. It screws that page up. I guess it loops to much and it says theres a problem with the script on this page. I need to make the page wait until it gets an answer from the form before it moves on to the next function. How do I do it? Heres the code.

<html>

<head>
<title> Legend of the Dragonstone </title>


<head>

<body>
<header>

<script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"> </script>

<script>



$(document).ready(function() {


function choosename() {
var name = "";
$("header").append("<p>Please enter your characters name.</p>");

// This is the problem loop.

do {
$("#button").click(function(){
$("p").hide();
var name = $("#text").val();
});
} while (name == "");
$("header").append("Welcome " + name +".");


};

function tarien() {
$("header").append("<p>City of Tarien</p>");
};


choosename();
tarien();

});

</script>

</header>

<body>

<input type="text" id="text">
<p></p>
<input type="button" value="ok" id = "button">

</body>

</html>