![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
Write a JavaScript/HTML program that inputs two integers a and bWrite 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 ![]() |
|||
|
#2
|
||||
|
||||
Re: Write a JavaScript/HTML program that inputs two integers a and bHave you tried anything? Post some code.
This looks like a homework assignment. You need to prove that you have put some effort into finding the answer. |
|
#3
|
|||
|
|||
Re: Write a JavaScript/HTML program that inputs two integers a and bhere try to check this one
javascript Syntax (Toggle Plain Text) 1. <?xml version="1.0" encoding="utf-8"?> 2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 4. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 5. <head> 6. <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> 7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 8. <meta http-equiv="Content-Style-Type" content="text/css" /> 9. <meta http-equiv="Content-Script-Type" content="text/javascript" /> 10. <title>JavaScript DEMO : Odd Numbers</title> 11. <style type="text/css"> 12. /* <![CDATA[ */ 13. table { 14. border : 1px solid #D0D0D0; 15. border-collapse : collapse; 16. text-align : left; 17. width : 70%; 18. } 19. td, th { 20. border-bottom : 1px solid #D0D0D0; 21. padding : .300em; 22. } 23. input[type='text'] { 24. border-bottom : 2px solid #D0D0D0; 25. color : #696969; 26. font-weight : bold; 27. height : 17px; 28. text-align : center; 29. } 30. /* ]]> */ 31. </style> 32. <script type="text/javascript"> 33. // <![CDATA[ 34. var result, odds, viaID; 35. viaID = Boolean( document.getElementBy ); 36. odds = []; 37. result = function() { 38. uA = parseInt((( viaID ) ? document.getElementById("unitA").value : document.all.unitA.value )); 39. 40. uB = parseInt((( viaID ) ? document.getElementById("unitB").value : document.all.unitB.value )); 41. 42. oLen = Math.max( uA, uB ); 43. min = Math.min( uA, uB ); 44. output = (( viaID ) ? document.getElementById("odd") : document.all.odd ); 45. 46. output.innerHTML = "<p>The odd number's between " + (Math.min( uA, uB)) + " and " + (Math.max( uA, uB)) + " are:</p><hr />"; 47. for ( var x = min; x <= oLen; x++ ) { 48. odds[x] = x / 2 ; 49. OdN = parseFloat( odds[x].toString().split(/(^\d+$)/)[0] ); 50. output.innerHTML += (( odds[(OdN * 2)] === undefined ) ? "" : "<b>" + ( OdN * 2 ) + "</b>, " ) 51. } output.innerHTML += "<hr />"; 52. }; 53. // ]]> 54. </script> 55. </head> 56. <body> 57. <div id="main"> 58. <table frame="box" rules="none" summary="Getting Odd number's between two integer"> 59. <caption><span>JavaScript DEMO:</span> Getting the Odd Number's Between A & B</caption> 60. <colgroup align="center"> 61. <col /> 62. <col /> 63. <col /> 64. </colgroup> 65. <thead> 66. <tr> 67. <th><label for="unitA">Unit A</label></th> 68. <th><label for="unitB">Unit B</label></th> 69. <th><button id="btn" name="btn" onclick="result();">Show The Odd's!</button></th> 70. </tr> 71. </thead> 72. <tfoot> 73. <tr> 74. <th>Result's</th> 75. <td colspan="2"><div id="odd" style="text-align: left;"></div></td> 76. </tr> 77. </tfoot> 78. <tbody> 79. <tr> 80. <td><input type="text" id="unitA" name="unitA" value="" size="10" /></td> 81. <td><input type="hidden" id="base" name="base" value="" /><input type="text" id="unitB" name="unitB" value="" size="10" /></td> 82. <td style="background-color : #ccc;"> </td> 83. </tr> 84. </tbody> 85. </table> 86. </div> 87. </body> 88. </html> |
Recent GIDBlog
Once again, no time for hobbies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Equation solver | RazoR | C Programming Language | 3 | 18-May-2008 10:24 |
| Write a C++ program to implement a cash register program | Computeretard66 | C++ Forum | 2 | 29-Feb-2008 09:05 |
| Airport Log program using 3D linked List : problem reading from file | batrsau | C Programming Language | 11 | 29-Feb-2008 08:44 |
| Two-Tier data dissemination code installation problem | nidhibansal1984 | Computer Software Forum - Linux | 6 | 16-Sep-2007 11:13 |
| Anyone can write a program code for this??? | chriskan76 | C Programming Language | 1 | 19-Oct-2004 21:25 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The