Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error on Page

Status
Not open for further replies.

xencade

MIS
Jul 16, 2002
10
US
<HTML>
<HEAD>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>

function getKeyCode()
{
var character = document.characterCode.character.value.substring(0,1);
var code = document.characterCode.character.value.charCodeAt(0);
var msg = &quot;The ASCII Decimal Key Code for the \&quot;&quot;+character+&quot;&quot; character is &quot;+code+&quot;.&quot;;
{
alert(msg);

}}
</script>
</HEAD>

<BODY>

<form name=&quot;characterCode method=&quot;post&quot; action=&quot;&quot; enctype=&quot;multipart/form-data&quot;>
<center>Type A Character
<input name=&quot;character&quot; maxlength=&quot;1&quot; size=&quot;1&quot; TYPE=&quot;text&quot;>
<input type=&quot;button&quot; value=&quot;Get ASCII Value&quot;
onClick=&quot;getKeyCode()&quot;>
</center>
</form>
</BODY>
</HTML>




Can anyone tell me why this won't work? What I need to change...
 
just missing a view &quot;'s and a extra one. try this
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>

function getKeyCode()
{
var character = document.characterCode.character.value.substring(0,1);
var code = document.characterCode.character.value.charCodeAt(0);
var msg = &quot;The ASCII Decimal Key Code for the \&quot;&quot; + character + &quot; character is &quot; + code + &quot; . &quot;;

alert(msg);

}
</script>
<form name=&quot;characterCode&quot; method=&quot;post&quot; action=&quot;&quot; enctype=&quot;multipart/form-data&quot;>
<center>Type A Character
<input name=&quot;character&quot; maxlength=&quot;1&quot; size=&quot;1&quot; TYPE=&quot;text&quot;>
<input type=&quot;button&quot; value=&quot;Get ASCII Value&quot; onClick=&quot;getKeyCode()&quot;>
</center>
</form>
You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
Iin msg, yoiu didn't escape the second pair of double quotes. To avoid that problem, I'd rewrite it using single quotes for the string:

var msg = 'The ASCII Decimal Key Code for the &quot;'+character+'&quot; character is '+code+'.';
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top