Search an element in a given array using JavaScript

Here is the JavaScript code.
  1. <html>  
  2.     <head>  
  3.         <script type="text/javascript">  
  4. function show_prompt()  
  5. {  
  6. var n=document.frm.text1.value;  
  7. if( n == "")  
  8. {  
  9. alert("Please enter the array size");  
  10. }  
  11. else  
  12. {  
  13. var a=new Array();  
  14. var temp;  
  15. for(i=0;i  
  16.             <n;i++)  
  17. {  
  18. var num=prompt("Please enter element of array"," ");  
  19. documentdocument.frm.arrayTxt.value=document.frm.arrayTxt.value+num+"\n";  
  20. a[i]=parseInt(num);  
  21. }  
  22. var flag=0;  
  23. var search=prompt("Enter the element to be searched ","");  
  24. for(i=0;i  
  25.                 <n;i++)  
  26. if(a[i]==search)  
  27. {  
  28. flag=1;  
  29. p=i+1;  
  30. }  
  31. if(flag==1)  
  32. alert("Element " +search + " found at position " +p);  
  33. else  
  34. alert("Sorry!, Element " + search + " not found ");  
  35. document.frm.text1.value="";  
  36. document.frm.arrayTxt.value="";  
  37. }  
  38. }  
  39.                 </script>  
  40.             </head>  
  41.             <body bgcolor="lightgreen">  
  42.                 <form name="frm">  
  43.                     <h3>To find an element in a given array </h3>  
  44.                     <hr color="green">  
  45. Enter the array size :   
  46.                         <input type="text" name="text1">  
  47.                             <br>  
  48.                                 <br>  
  49.                                     <input type="button" onclick="show_prompt()" value="Submit">  
  50.                                         <br>  
  51.                                             <br>  
  52.                                                 <textarea name="arrayTxt" rows="10" cols="4"></textarea>  
  53.                                                 <br>  
  54.                                                 </form>  
  55.                                             </body>  
  56.                                         </html>  
Thank you, keep learning and sharing