Problem with Radio Buttons and Response

Hello again! I have moved to JavaScript and am having problems with an example. I have decided to try handling it bit by bit. The first issue I am dealing with, though, appears to be an HTML issue rather than a JavaScript issue.

Specifically, I have a question, “Are you the President?”, with two radio buttons labeled “Yes” and “No”. If the user checks Yes, the browser should display the phrase “Mr. President”. If the user checks No, the browser should display “Sir”. I can get the Sir when I click yes, but I can’t get the “Mr. President” when I click no. If I eliminate the Mr. and just have President, it works. The problem is that several examples in my book of both document.write quotes and alert quotes allow phrases that include punctuation and spaces. So why is it not working in this example?

Here is the code. I have run it as both a document.write and an alert. FYI, the next step is to try to assign a value to a variable when I click a choice rather than do a doc write or an alert. I would then use the variable in my script.

<html>
<body>

<form>
<p>Are you the President?<br />
<input type=“radio” name=“pres” value=“no” onclick=alert(“Sir”) />No<br />
<input type=“radio” name=“pres” value=“yes” onclick=alert(“Mr President”) />Yes</p>
</form>

</body>
</html>

Thanks!

<html>
<body>

<form action="">
<p>Are you the President?<br />
<input type="radio" name="pres" value="no" onclick="alert('Sir')"/>No<br />
<input type="radio" name="pres" value="yes" onclick="alert('Mr. President')" />Yes</p>
</form>

</body>
</html>

document.write always writes to a new page if the current page has finished loading.

There are two ways to update the current page. The standard way is to use the appropriate DOM commands, the alternative that most browsers support is to use innerHTML. If you use innerHTML you’ll need a tag after the radio buttons to update with the new content. If you use DOM commands you can add the new content without needing anything extra there at the start.

Thank you. Now - next question. I changed the alert to document.write. It gave me the text response I wanted, but it did so on a new page. Is there any way to make the text response appear on the same page as and below the question with the radio buttons?