Write a JavaScript/HTML program that inputs two integers a and b in an input text box, and outputs all odd numbers between
a and b (a and b are expected to be between 1 and 30, and a<b)

Can somebody help me with the source code for the .html file

Thanks a million :)

Your zero interest in subject, brought you to another bad situation and you posted in Java section. Java is NOT JavaScript

Request to move this post to correct section already sent...

Try this:

<?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" xml:lang="en" lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<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>JavaScript DEMO : Odd Numbers</title>
<style type="text/css">
/* <![CDATA[ */
table {
  border : 1px solid #D0D0D0;
  border-collapse : collapse;
  text-align : left;
  width : 70%;
}
td, th {
  border-bottom : 1px solid #D0D0D0;
  padding : .300em;
}
input[type='text'] {
  border-bottom : 2px solid #D0D0D0;
  color : #696969;
  font-weight : bold;
  height : 17px;
  text-align : center;
}
/* ]]> */
</style>
<script type="text/javascript">
// <![CDATA[
var result, odds, viaID;
viaID = Boolean( document.getElementBy );
odds = [];
result = function() {
uA = parseInt((( viaID ) ? document.getElementById("unitA").value : document.all.unitA.value ));

uB = parseInt((( viaID ) ? document.getElementById("unitB").value : document.all.unitB.value ));

oLen = Math.max( uA, uB );
min = Math.min( uA, uB );
output = (( viaID ) ? document.getElementById("odd") : document.all.odd );

   output.innerHTML = "<p>The odd number's between " + (Math.min( uA, uB)) + " and " + (Math.max( uA, uB)) + " are:</p><hr />";
   for ( var x = min; x <= oLen; x++ ) {
   odds[x] = x / 2 ;
   OdN = parseFloat( odds[x].toString().split(/(^\d+$)/)[0] );
   output.innerHTML += (( odds[(OdN * 2)] === undefined ) ? ""  : "<b>" + ( OdN * 2 ) + "</b>, " )
   } output.innerHTML += "<hr />";
};
// ]]>
</script> 
</head>
<body>
<div id="main">
<table frame="box" rules="none" summary="Getting Odd number&apos;s between two integer">
<caption><span>JavaScript DEMO:</span> Getting the Odd Number's Between A &amp; B</caption>
<colgroup align="center">
<col />
<col />
<col />
</colgroup>
<thead>
<tr>
<th><label for="unitA">Unit A</label></th>
<th><label for="unitB">Unit B</label></th>
<th><button id="btn" name="btn" onclick="result();">Show The Odd's!</button></th>
</tr>
</thead>
<tfoot>
<tr>
<th>Result&apos;s</th>
<td colspan="2"><div id="odd" style="text-align: left;"></div></td>
</tr>
</tfoot>
<tbody>
<tr>
<td><input type="text" id="unitA" name="unitA" value="" size="10" /></td>
<td><input type="hidden" id="base" name="base" value="" /><input type="text" id="unitB" name="unitB" value="" size="10" /></td>
<td style="background-color : #ccc;">&#32;</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>

There's been some changes in my first posted code, and you will need to replace the whole <script></script> block, to this one.
I've removed all unnecessary line's in the code:

<script type="text/javascript">
// <![CDATA[
var result, odds, viaID, oLen, min;
viaID = Boolean( document.getElementBy );
odds = [];
result = function() {
uA = parseInt((( viaID ) ? document.getElementById("unitA").value : document.all.unitA.value ));

uB = parseInt((( viaID ) ? document.getElementById("unitB").value : document.all.unitB.value ));

oLen = Math.max( uA, uB );
min = Math.min( uA, uB );
output = (( viaID ) ? document.getElementById("odd") : document.all.odd );

   output.innerHTML = "<p>The odd number's between " + min + " and " + oLen + " are:</p><hr />";
   for ( var x = min; x <= oLen; x++ ) {
   odds[x] = x / 2 ;
   OdN = parseFloat( odds[x].toString().split(/(^\d+$)/)[0] );
   output.innerHTML += (( odds[(OdN * 2)] === undefined ) ? ""  : "<b>" + ( OdN * 2 ) + "</b>, " )
   } output.innerHTML += "<hr />";
};
// ]]>
</script>
This article has been dead for over six months. Start a new discussion instead.