hello. This might be a silly question, but I'm having no clue why it wouldn't work out. I'm simply trying to have a string, "job done", into a input text box.
Here's the code I'm working on.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<title>text output testing</title>
<script language="javascript" type="text/javascript">
function print()
{
document.getElementById('output').innerHTML="job done"
}
</script>
</head>
<html>
<body>
<input type="text" id="output"><input type="button" onclick="print();" value="Go">
</body>
</html>
I thought this should work like a breeze, but it makes my bang my head on the wall. Any suggestion will be appreciated.
print is a javascript reserved word. It is a method of the window Global Object, window.print(). Change the name of your function: Print() or printIt() or whichever
On the other hand, the non empty tags (such as INPUT) have no innerHTML, they might have the value attribute
And, the last but the least, there is a mismatch between your Doctype (HTML transitional) and the notation of some of your tags < ... />, which is an XHTML notation, not an HTML one. And you miss your opener tag <html>. And language is deprecated,
Bookmarks