I'm getting the error saying findBid() is not defined when I clicked on the Bidding Result button. I can't figure out why as the function findBid() works fine when I call it normally. Help is appreciated. <html> <head> <title>Bidding Application</title> <script type="text/javascript"> var a=new Array(5), b=new Array(5), initialValue, bidVal1, bidUser, j=0, bidVal; function setItemValue(){ initialValue=BasePrice.BasePri.value; for (j=0;j<5;j++){ window.alert("Initial value of item is RM"+initialValue); bidUser=window.prompt("Enter your user name, user no. "+j+":","Name"); bidVal1=window.prompt("Enter your bid for the vase, must be higher than RM"+ initialValue+":",initialValue); bidVal=parseFloat(bidVal1); while (bidVal<initialValue){ bidVal1=window.prompt("Sorry, your bid is lower than the base price. Please enter a bid higher than the base price.\n Enter your bid for the vase, must be higher than RM"+ initialValue+":"); bidVal=parseFloat(bidVal1); } a[j]=bidUser; window.alert("a["+j+"]="+ bidUser); b[j]=bidVal; window.alert("b["+j+"]="+ bidVal); } makeTable(); } function makeTable(){ document.write("<table border=\"1\" width=\"50%\">"); document.write("<caption>Bidding Table</caption>"); document.write("<thead><tr><th>User ID</th><th>Bidding Value</th></tr></thead><tbody>"); for (j=0;j<5;j++){ document.write("<tr><td>"+a[j]+"</td><td>"+b[j]+"</td></tr>"); } document.write(" </tbody></table><br /><input id='BidRes' type='button' value='Bidding Result' onclick='findBid()' />"); } function findBid(){ var largest=initialValue, counter=0; for (j=0;j<5;j++){ if (b[j]>largest){ largest=b[j]; counter=j; } } window.alert("The winner of the bid is "+a[counter]+"\nThe end bid is "+b[counter]); } </script> </head> <body> <form name="BasePrice" method="post" action=""> <label>Enter value for "a vase" : <input id="BasePri" type="text" value="" size="10" /> </label> <br /> <input name="OKBut" type="button" value="OK" onClick="setItemValue()" /> <input name="CanBut" type="reset" value="Cancel" /> </form> </body> </html>