When I enter the integer, I'm not getting the prompt that states if it is odd or even. I am new to this, so this stupid thing has taken me a week to do, but now I am just frustrated. Can someone help me out.

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns = "http://www.w3.org/1999/xhtml">

<title>Odd or Even</title>

<script type = "text/javascript">
<!--

// Determine if number is odd or even
Function OddEven(number)

// convert number from type string to type Int
x = Integer.parseInt ( xNumber );
if ( x % 2 == 0 )
if ( x % 2 != 0 )
// display odd or even integer
document.writeln(
"<h1>Integer is "odd or even"</h1>" );
End If
End Function

// Convert input to long integers
Sub CmdButton_OnClick()
Dim number
number=CLng(Document.forms(0).n1.Value)

Call OddEven(number)
End Sub
// -->
</script>

<body>
<form name="form1" id="form1" method="post" action="">
<p>
<input type="text" name="n1" />
Enter a number greater than 0</p>
<p>
<input type="submit" name="CmdButton" value="Compute" />
</p>
<p>
<input type="reset" name="Reset" value="Reset" />
</p>
</form>
</body>
</html>
3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by sysel

You could try this, if you are referring the whole thing in Javascript:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<?xml-stylesheet type="text/css" href="#css21" media="screen"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html id="xhtml10S" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="Window-Target" content="_top" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<title>Free Live Help!</title>
<style id="css21" type="text/css" media="screen">
/* <![CDATA[ */

/* ]]> */
</style>
<script type = "text/javascript">
<!--

var OddEven = function( number ) {
var x = number.n1.value * 1;
if (( x % 2 ) === 0 ) {
} else {
} if ( number.n1.value !== "" ) {
document.writeln(
"<h1>This ( " + x + " ) Integer is an " + alertMessage + " number</h1>" );
} return false;
};

// -->
</script>
<body>
<div id="main">
<form id="form1" method="post" action="#" onsubmit="return OddEven( this );">
<div>
<p>
<input type="text" id="n1" name="n1" value="" />Enter a number greater than 0</p>

<p><input type="submit" name="CmdButton" value="Compute" />
</p>
<p>
<input type="reset" name="Reset" value="Reset" /></p>
</div>

</form>
</div>
</body>
</html>

essential

Thanks, that did the trick!