0

I have searched many sites, and i have done everything as it was stated, however my code still wont work.

    <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Cím</title>
<style>
    #yourname {
        color: red;
        font-size: 16pt;
        }
    #yourbday {
        color: blue;
        font-weight: bold;
        font-size: 16pt;
    }
</style>

<script>
function starting(yname, ybday){
    alert ("Hi");
    var yname = prompt ("What's your name?");
    var ybday = prompt ("What's your age?", "20");
    document.write("<span id='yourname'>" + yname + "</span>");

}
</script>

</head>

<body onload="starting()">


</body>

However, in the body, the your name string is not formatted. How can I solve this problem? Thanks!

sy000
  • 1
  • 1
    The problem is that `document.write` is blowing away your document, because the document is closed when `onload` fires. To fix this you'd need to use something other than `document.write`, which is why I've closed this as a duplicate of the other question. – zzzzBov Sep 12 '16 at 15:06
  • 1
    You are calling the function but you are not sending it any parameters (yname, ybday) – Ram Segev Sep 12 '16 at 15:06

0 Answers0