Problem with alert().

Problem with alert().

hello guys!!
someone please help me with my problem.
i have html page having 2 <a></a> tags and a script which gets url variable and one of the anchor work with that variable and other is just like a back button.the issue is the alert() in the script is not working secondly the the 1st anchor is not working according to the script means i can not click that anchor.here is the code:
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <meta charset="utf-8" />
  5. <link rel="stylesheet" href="./style.css" type="text/css"/>
  6. <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js"></script>
  7. <script language="javascript" type="text/javascript">
  8. $(document).ready(function(){
  9. $('#addtocart').on('pageshow', function(event) {
  10.     var proid=getUrlVars()["productid"];
  11.     var url_link="http://localhost:8080/magento/index.php/checkout/cart/add?"+proid+"&qty;=1";
  12. document.getElementById("add").setAttribute("href",url_link);
  13. });
  14.                            });
  15.     function getUrlVars() {
  16.     var vars = {};
  17.     var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
  18.         vars[key] = value;
  19.     });
  20.     return vars;
  21. }
  22.    
  23. </script>
  24.     <title>ADD TO CART</title>
  25. </head>
  26. <body>
  27. <div id="addtocart" data-role="page" data-add-back-btn="true">
  28.     <div class="header">
  29.       <h1 class="page-tile">HI-AT & SAFERTECH</h1>
  30.     </div>
  31.     <div class="body">
  32.         <p class="description" contenteditable="true">DO YOU REALLY WANT IT TO ADD TO CART</p>
  33.         <div class="loginregister">
  34.            <!-- <input type="button" class="login" value="YES"><a href="http://localhost:8080/magento/index.php/checkout/cart/add?product=4&qty;=1"></a></input>-->
  35.              <a id="add">yes</a>
  36.             <a  class="back" href="#" onClick="history.back();">cancel</a>
  37.         </div>
  38.     </div>
  39.     <div class="footer">
  40.         <hr />
  41.         <p>
  42.             Copyright © 2011 HI-AT & SAFER TECH. All rights reserved.
  43.         </p>
  44.     </div>
  45. </div>
  46. </body>
  47. </html>



i just want when i click the "YES" it should work like the script says and when i click "cancel" take me back to the previous page.Please tell me is there anything i am doing wrong.