Hi is that anyone who can help me in javaScript program i di

Hi is that anyone who can help me in javaScript program. i did most of the program but i need help in Palindromic Prime and also i need a help in check box and find box.

Here is the program what i have it here is mine prime.Html file..

<html>

<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />

<title>LeapYears</title>

<script type=\"text/javascript\" src=\"p1pprime.js\">>

  
      
</script>


</head>


<body>
<form name=\"numbers\">

Staring value(>1): <input type=\"text\" name=\"firstNum\" />
           Ending Value(<99999: <input type=\"text\" name=\"secondNum\" />
           <left>      
   <p>Select what you want:<br />

<input type =\"checkbox\" name=\"color\" id=\"rbutton1\"
value=\"Find\" onclick=\"calcPrimeNumber()\"/>
<label for=\"rbutton1\">Prime</label>
<br />
<input type=\"checkbox\" name=\"color\" id=\"rbutton2\" value=\"find\" onclick=\"checkPalindrome();\" />
<label for=\"rbutton2\">Palindrome</label>
<br />
<input type =\"checkbox\" name=\"color\" id=\"rbutton3\"
value=\"yellow\"/>
<label for=\"rbutton3\">Palindromic Prime</label>
</left>
<br> <input type=\"button\" value=\"Find\" onclick=\"checkbox\" />
<button onclick=\"closeWin()\">Close \"myWindow\"</button></br>
</form>
<div id=\"output_content\">
</div>
</body>


</html>

Here is p1pprime.js

function calcPrimeNumber(){

var beginNum = parseInt(document.numbers.firstNum.value);
var endNum = parseInt(document.numbers.secondNum.value);
var primeNumbs = new Array();


var ctr = beginNum;
while(ctr<=endNum)
{
if(isPrime(ctr)==true)
{
primeNumbs[primeNumbs.length] = ctr;
}
ctr = ctr+1;

}

if (primeNumbs.length == 0){
document.getElementById(\'output_content\').innerHTML = \"There were no prime no within the range.\";
}

else {
outputPrimeNums(primeNumbs);
}

}

function isPrime(num)
{
var flag = true;
for(var i=2; i<=Math.ceil(num/2); i++)
{
if((num%i)==0)
{
flag = false;
break;
}
}
return flag;
}

function outputPrimeNums(primes){
var html = \"<h2>Prime Numbers</h2>\";
      
for (i=0;i<primes.length;i++){
html += primes[i] + \"<td/>\";
}
document.getElementById(\'output_content\').innerHTML = html;
          
}
      
       function checkPalindrome(){
var beginNum = parseInt(document.numbers.firstNum.value);
var endNum = parseInt(document.numbers.secondNum.value);
var ctr = beginNum;
while(ctr<=endNum){
num = ctr;
temp = 0;
while(num>0){
// get last digit;
temp = (temp*10)+num%10;
// reduce number by deleting last digit.
num = parseInt(num/10);
}
if(temp == ctr){
document.write(ctr +\"       \");
}
else{
}
ctr = ctr+1;
}
}

Solution

Prime.html:

<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />
<title>LeapYears</title>
<script type=\"text/javascript\" src=\"p1pprime.js\">
</script>

</head>

<body>
<form name=\"numbers\">
Staring value(>1): <input type=\"text\" name=\"firstNum\" />
Ending Value(<99999: <input type=\"text\" name=\"secondNum\" />
<left>
<p>Select what you want:<br />
<input type =\"checkbox\" name=\"color\" id=\"rbutton1\"
value=\"Find\" />
<label for=\"rbutton1\">Prime</label>
<br />
<input type=\"checkbox\" name=\"color\" id=\"rbutton2\" value=\"find\" />
<label for=\"rbutton2\">Palindrome</label>
<br />
<input type =\"checkbox\" name=\"color\" id=\"rbutton3\"
value=\"yellow\"/>
<label for=\"rbutton3\">Palindromic Prime</label>
</left>
<br> <input type=\"button\" value=\"Find\" onclick=\"onFind()\" />
<button onclick=\"closeWin()\">Close \"myWindow\"</button></br>
</form>
<div id=\"output_content1\">
</div>
<div id=\"output_content2\">
</div>
<div id=\"output_content3\">
</div>
</body>

</html>

p1pprime.js:

function onFind(){
           var chk_arr = document.getElementsByName(\"color\");
           var chklength = chk_arr.length;   

           if(chk_arr[0].checked == true){
               calcPrimeNumber();
           }
          
           if(chk_arr[1].checked == true){
               checkPalindrome();
           }
          
           if(chk_arr[2].checked == true){
               checkPalindromicPrime();
           }
       }
function calcPrimeNumber(){
var beginNum = parseInt(document.numbers.firstNum.value);
var endNum = parseInt(document.numbers.secondNum.value);
var primeNumbs = new Array();

var ctr = beginNum;
while(ctr<=endNum)
{
if(isPrime(ctr)==true)
{
primeNumbs[primeNumbs.length] = ctr;
}
ctr = ctr+1;
}
if (primeNumbs.length == 0){
document.getElementById(\'output_content1\').innerHTML = \"There were no prime no within the range.\";
}
else {
outputPrimeNums(primeNumbs,\'output_content1\',\'Prime Numbers\');
}
}
function isPrime(num)
{
var flag = true;
for(var i=2; i<=Math.ceil(num/2); i++)
{
if((num%i)==0)
{
flag = false;
break;
}
}
return flag;
}
function outputPrimeNums(primes,div_id,html_header){
var html = \"<h2>\"+html_header+\"</h2>\";
  
for (i=0;i<primes.length;i++){
html += primes[i] + \" <td/>\";
}
document.getElementById(div_id).innerHTML = html;
  
}
  
function checkPalindrome(){
           var beginNum = parseInt(document.numbers.firstNum.value);
           var endNum = parseInt(document.numbers.secondNum.value);
           var ctr = beginNum;
           var html = \"<h2>Palindrome Numbers</h2>\";
           while(ctr<=endNum){
           num = ctr;
           temp = 0;
           while(num>0){
               // get last digit;
               temp = (temp*10)+num%10;
               // reduce number by deleting last digit.
               num = parseInt(num/10);
           }
           if(temp == ctr){
               html += ctr + \" <td/>\";
           }
           else{
           }
           ctr = ctr+1;
           }
           document.getElementById(\'output_content2\').innerHTML = html;
       }
      
       function checkPalindromicPrime(){
           var beginNum = parseInt(document.numbers.firstNum.value);
           var endNum = parseInt(document.numbers.secondNum.value);
           var ctr = beginNum;
           var primeNumbs = new Array();
           while(ctr<=endNum){
           num = ctr;
           temp = 0;
           while(num>0){
               // get last digit;
               temp = (temp*10)+num%10;
               // reduce number by deleting last digit.
               num = parseInt(num/10);
           }
           if(temp == ctr){
               if(isPrime(ctr)==true)
{
primeNumbs[primeNumbs.length] = ctr;
}
           }
           else{
           }
           ctr = ctr+1;
           }
           outputPrimeNums(primeNumbs,\'output_content3\',\'Palindromic Prime Numbers\');
       }

Hi is that anyone who can help me in javaScript program. i did most of the program but i need help in Palindromic Prime and also i need a help in check box and
Hi is that anyone who can help me in javaScript program. i did most of the program but i need help in Palindromic Prime and also i need a help in check box and
Hi is that anyone who can help me in javaScript program. i did most of the program but i need help in Palindromic Prime and also i need a help in check box and
Hi is that anyone who can help me in javaScript program. i did most of the program but i need help in Palindromic Prime and also i need a help in check box and
Hi is that anyone who can help me in javaScript program. i did most of the program but i need help in Palindromic Prime and also i need a help in check box and

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site