Hi Friends,
This is what I am trying to achieve.
I have a page in which there is a option for an user to click on a button(type=image) and once it is clicked it will add that item to the list which is on the same page so the page refresh/js location .
My current code is structured this way for this add function.
Assume here is the "
Image" button next to an item so when this is clicked the below js function adds it to the list(can consider like the add to cart thing)
Current JS.
function addItem(item) {
function getArgs() {
var args = new Object();
var query = location.search.substring(1);
var pairs = query.split("&");
var newstring = "";
for(var i = 0; i < pairs.length; i++){
var pos = pairs[i].indexOf('=');
if (pos == -1) continue;
var argname = pairs[i].substring(0,pos);
if(argname.toLowerCase() != "siteid" && argname.toLowerCase() != "urlpull" && argname.toLowerCase() != "exstyle" && argname.toLowerCase() != "aitems" && argname.toLowerCase() != "mitem" && argname.toLowerCase() != "ditems"){
newstring += pairs[i] + "&";
}
}
return newstring;
}
if (getArgs()) { urlString = getArgs(); }
else { urlString = ''; }
window.location = location.pathname + '?' + urlString + 'aitems=' + item + '#itemList';
}
//Code ends here.
Here, the idea is to show the user in someway that the item is being added to the list on the side and they can click OK to close the alert box.Currently there is no way that they will know its being added unless they check it in the list to see if its added.
I tried the usual alert method and it works fine. So when they click the image button it alerts them saying "Item Added" and if they click ok the page loads with the updated list...so this is fine..but I have the criteria of not to have this usual default boring Alert box so I found this site
http://slayeroffice.com/code/custom_alert/ (please scroll down for the code here).
to customize the alert window. I was able to get this working but the problem(main issue) is if they click the image the Alert box appears but before they click OK the page refreshes and alert box disappears on its own but if they click the image button for second time then the alert box stays till they click OK and the page gets loaded as usual...
I added my Alertbox in the last to the above JS and also tried adding that to the html code..both way it works with the default alert box but I am struck here as the look and feel for the box should be different.
Hope this information is helpful to guide me..Please help me out.
Other ideas that I thought of :
1) show the Alert box after the page is loaded by adding the item saying "You item has been added to the list".
or
2)I was thinking to show some message in the DIV once they click the image button and after the page loads..
But I am not able to do it though.
I read it in many sites that customizing the alert box is not possible but the way the above site had done works as a standalone alert box but not with my code.
Waiting for the help.
Regards
Pragan