Jump to content

innerHTML doesn't change in prompt box


mpsn

Recommended Posts

Hi, why doesn' this simple script run?

 

<html>
<head>
<script type="text/javascript">
function show_prompt()
{
var name=prompt("Please enter your name","Harry Potter");
if (name!=null && name!="")
  {
  var text = document.getElementsById("p_1").innerHTML = "What's up, " + name + "?";
  }
}
</script>
</head>
<body>
<input type="button" onclick="show_prompt()" value="Show prompt box" />
<p id="p_1">Initial text</p>

</body>
</html>

 

Any help appreciated.

Link to comment
https://forums.phpfreaks.com/topic/253410-innerhtml-doesnt-change-in-prompt-box/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.