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:
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <link rel="stylesheet" href="./style.css" type="text/css"/>
- <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js"></script>
- <script language="javascript" type="text/javascript">
- $(document).ready(function(){
- $('#addtocart').on('pageshow', function(event) {
- var proid=getUrlVars()["productid"];
- var url_link="http://localhost:8080/magento/index.php/checkout/cart/add?"+proid+"&qty;=1";
- document.getElementById("add").setAttribute("href",url_link);
- });
- });
- function getUrlVars() {
- var vars = {};
- var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
- vars[key] = value;
- });
- return vars;
- }
-
- </script>
- <title>ADD TO CART</title>
- </head>
- <body>
- <div id="addtocart" data-role="page" data-add-back-btn="true">
- <div class="header">
- <h1 class="page-tile">HI-AT & SAFERTECH</h1>
- </div>
- <div class="body">
- <p class="description" contenteditable="true">DO YOU REALLY WANT IT TO ADD TO CART</p>
- <div class="loginregister">
- <!-- <input type="button" class="login" value="YES"><a href="http://localhost:8080/magento/index.php/checkout/cart/add?product=4&qty;=1"></a></input>-->
- <a id="add">yes</a>
- <a class="back" href="#" onClick="history.back();">cancel</a>
- </div>
- </div>
- <div class="footer">
- <hr />
- <p>
- Copyright © 2011 HI-AT & SAFER TECH. All rights reserved.
- </p>
- </div>
- </div>
- </body>
- </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.