JavaScript - Help With Java Mini Cart Code
I am looking for help to develop a java code for my e-commerce site mini cart.
I have looked locally (kijiji) and on Coding Forums market place and haven't received a great response. Either the person had other projects they were working on or they were trying to "sell" me more than what I was asking for (ie web and graphic design). I have a mini cart on my site that I would like to have a few specific features. I am hoping someone in this forum can help me out (as I have received wonderful help before!!) I need a javascript code/feature that will: - highlight the most recent item that has been added to slide down mini cart window - refresh the mini cart div content to update item count and price. On the site I am hosted on there is a built in feature to show how many items are in the cart and total price, but I don't know how to get it to update successfully - when slide down mini cart window refreshes it should'nt scroll to the top (if there is a scrollbar) ie: looking to implement a javascript: void (0) if possible - have the slide down minicart window appear for 5-10 seconds then automatically slide back up. (the visitor can also have the option to close the window before the 5 seconds) I would really appreciate any help with this. I find javascript hard and I have tried to learn it, but unfortunately I can't seem to grasp it . Similar TutorialsHi all, I have just joined this forum hoping for some help on a problem i am having, i have a feeling the solution is simple but im a noob at JAVA so i have no idea how to work it out. The site is.... http://inspirecalendar.net/html/purchase.html The problem is the following.... When you select US (West Coast) as your location it doesn't update the price on the right properly. If you select it first it just won't display anything. if you select it after choosing another one and hitting continue then it doesn't change. Any help would be appreciated, hope i explain the problem properly if you have any questions feel free to ask... Thnks in advance :Smiley Hi guys.. I really need a bit of help.. is anyone looking at this good with JS? I have a php form validation script but i think its a bit slow and would rather a JS script instead... here is what i have in php.. PHP Code: <?php if(isset($_POST['submit'])) { $firstName = $_POST['firstName']; $lastName = $_POST['lastName']; $email = $_POST['email']; $mobile = $_POST['mobile']; $comments = $_POST['comments']; $errors = array(); function display_errors($error) { echo "<p class=\"formMessage\">"; echo $error[0]; echo "</p>"; } function validateNames($names) { return(strlen($names) < 3); } function validateEmail($strValue) { $strPattern = '/([A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4})/sim'; return(preg_match($strPattern,$strValue)); } function validateMobile($strValue) { $strPattern = '/^\d{10}$/'; return(preg_match($strPattern,$strValue)); } function validateComments($comments) { return(strlen($comments) < 10); } if(validateNames($firstName)) { $errors[] = 'Please Enter Your First Name'; } if(validateNames($lastName)) { $errors[] = 'Please Enter Your Second Name'; } if(!validateEmail($email)) { $errors[] = 'Please Enter Your Correct Email'; } if(!validateMobile($mobile)) { $errors[] = 'Please Enter Your Correct Mobile Number'; } if(validateComments($comments)) { $errors[] = 'Please Enter A Comment More Than 10 Characters'; } if(empty($errors)) { $to = "info@eventpromotion.ie"; $subject = "Event Promotion Enquiry!"; $body = "First Name: " . $_POST['firstName'] . "\nLast Name: " . $_POST['lastName'] . "\nEmail: " . $_POST['email'] . "\nMobile: " . $_POST['mobile'] . "\nMessage: " . $_POST['comments']; $headers = "From: ". $firstName ." ". $lastName . " <" . $email . ">\r\n"; if (mail($to, $subject, $body, $headers)) { echo("<p class=\"formMessage\">Thanks for submitting your enquiry.</p>"); } else { echo("<p class=\"formMessage\">Message delivery failed.</p>"); } } else { //echo "error"; display_errors($errors); } } ?> <form id="form" method="post" action="index.php#quickContact"> <p> <label>First Name</label><br /> <input type="text" name="firstName" value="<?php if(isset($firstName)){echo $firstName;} ?>" /> </p> <p> <label>Last Name</label><br /> <input type="text" name="lastName" value="<?php if(isset($lastName)){echo $lastName;} ?>" /> </p> <p> <label>Email:</label><br /> <input type="text" name="email" value="<?php if(isset($email)){echo $email;} ?>" /> </p> <p> <label>Mobile:</label><br /> <input type="text" name="mobile" value="<?php if(isset($mobile)){echo $mobile;} ?>" /> </p> <p> <label>Comments:</label> <br /> <textarea name="comments" cols="30" rows="3" ><?php if(isset($comments)){echo $comments;} ?></textarea> </p> <p> <input class="send" type="image" src="images/submit2.gif" name="submit" value="Submit" /></p> </form> does anyone know how to transfer this to JS so that it will be easy to understand.. Im not good with JS at all Hello All, So, I have a website with a floating cart and it loads fine and works almost flawlessly lol. However, when a person has a bunch of items in their cart, and they want to minimize it for the rest of their browsing experience, every time a new page loads, or a refresh happens, the floating cart un-minimizes and expands out fully again displaying all the items. This can become very annoying during the shopping experience when you have a bunch of items loading and just taking up space in the browser. Therefore, I am wondering if their is some html or script that would save the minimizing in the floating cart, and carry it over to the next page, and the rest of the browsing on site? Thank you for any suggestions/help. I am new to HTML and script writing, but I am eager to learn. Hopefully in the future, I won't be paying for little changes like this every time I need one. Ok, so i need help writing a java script that will look at a bunch of numbers and output the highest one so what i need is for it to do something like this. (A is my input value) (B is my output value) the (A) value will be constantly changing and with the script has to do is look at all of those values and output them to (b) if anyone knows how to do this i would be so grateful if they could write the code for me because i'm new to coding and i really need this to work. thanks. hello, i am looking a a specific javascript code for a school project. what the code does is it re-sizes your window to a specific size, and then makes it jump around to the four corners of your screen. a perfect example of this would be the rick roll site called http://www.20b.org/rickroll.html its best viewed in internet explorer, and will take effect after you allow it on the top pop up window. it seems that the latest version of firefox disables the window resizing and movement, so use IE. after examining the page source, i managed to find this code. window.resizeTo(640,625); window.moveTo(0,0); for (i = 1; i <= 9; i++){ setTimeout('window.moveTo(1599,1199);', i+"000"); i++; setTimeout('window.moveTo(0,1199);', i+"000"); i++; setTimeout('window.moveTo(1599,0);', i+"000"); i++; setTimeout('window.moveTo(0,0);', i+"000"); } the code worked perfectly on the macs used at school. but however, when i took it home and tried it on my PC, which has a different sized monitor, it didnt work right. my copied code section seemed to jump off the edges of the screen, like it was using the size of a Macs monitor, yet the original website works fine. this led me to believe that the source code seems to find the size of the monitor and adjust the position of where it moves. i cant seem to find that part of the code. any help would be appreciated Hello, I'm making a Javascript implementation for my Java program. But I'm having a proplem. I want to call my own Java code from the Javascript script. Is that possible? Thanks, enderp Pls help me on how to edit opera mini pls help
Hi All, I am trying to create a website and am having problems editing a piece of code. A working example can be seen Here The only problem is that the "pages" are open when a user arrives on the site and I want them to be " closed" until a user clicks them, much like the "Search, Profile & Draw" tabs. I have included all the coding used to this, the only thing I haven't included are the images. Anyone got any idea how this is possible? Regards Jake Can you place java code in an external javascript file (.js). For example can I do the following in my xx.js file. $(document).ready(function(){ <% execute some java code here %> ...execute some javascript code here... }) Can I do the above? Another question ... I know <% %> is to execute java code inside html. But what does <%-- - -%> mean? Thanks for any help. Hi First sorry for my bad English! may any one interpret the JavaScript code below for me? A Device code ( a "random number") and the DVD code gives an activation code! Each install time a random number and thus a new activation code! i works in cookie base manner! clear cookie couse program become unusable and another activation will be needed! I want to change random Number to a fix one so it Becomes constant and does not change regularly! and then no need for change activation code... Where do I change? I'm sure help ... best regards thanks ----------------------------------------------------------------------------------- <html> <head> <title>Activation</title> <script type="text/javascript" src="../js/ajax.js"></script> <script type="text/javascript"> var _0x8834=["\x72\x65\x70\x6C\x61\x63\x65","\x68\x72\x65\x66", "\x6C\x6F\x63\x61\x74\x69\x6F\x6E","\x73\x65\x72\x 69\x61\x6C","\x61\x63\x74\x69\x76\x61\x74\x69\x6F\ x6E\x43\x6F\x64\x65","\x72\x61\x6E\x64","\x73\x75\ x62\x73\x74\x72\x69\x6E\x67","\x4D\x6F\x62\x69\x55 \x70\x54\x6F\x44\x61\x74\x65\x5F\x33","\x4D\x6F\x6 2\x69\x55\x70\x54\x6F\x44\x61\x74\x65\x5F\x34","\x 4D\x6F\x62\x69\x55\x70\x54\x6F\x44\x61\x74\x65\x5F \x35","\x2E\x2E\x2F\x4D\x6F\x62\x69\x55\x70\x54\x6 F\x44\x61\x74\x65\x2E\x68\x74\x6D\x3F"];function GET(){var _0x84efx2={};var _0x84efx3=window[_0x8834[2]][_0x8834[1]][_0x8834[0]](/[?&]+([^=&]+)=([^&]*)/gi,function (_0x84efx4,_0x84efx5,_0x84efx6){_0x84efx2[_0x84efx5]=_0x84efx6;} );return _0x84efx2;} ;if(GET()[_0x8834[3]]!=undefined&&GET()[_0x8834[4]]!=undefined&&GET()[_0x8834[5]]!=undefined){var num=(parseInt(GET()[_0x8834[3]][_0x8834[6]](0,7))%5555)*(parseInt(GET()[_0x8834[5]]%30)+1);if(num==parseInt(GET()[_0x8834[4]])){setf(_0x8834[7],GET()[_0x8834[5]]);setf(_0x8834[8],GET()[_0x8834[3]]);setf(_0x8834[9],GET()[_0x8834[4]]);window[_0x8834[2]]=_0x8834[10];} ;} ; </script> </head> <body align="center"> <h1>Activation</h1> To get activation code visit*************<br> <script language="javascript"> if (GET()['serial']!=undefined) document.write('<br>Incorrect serial or activation code. Try again please!<br>'); </script> <form action="./activation.htm?" method="GET"> <table align="center"> <tr> <td>Device code:</td> <td><script language="javascript"> if (getf('rand_num')==undefined) setf('rand_num', Math.floor(Math.random()*9999)); var rand_num=getf('rand_num'); document.write(rand_num+'<INPUT TYPE="hidden" NAME="rand" VALUE="'+rand_num+'">'); </script></td> </tr> <tr> <td>Serial</td> <td> <input name="serial"></input></td> </tr> <tr> <td>Activation code</td> <td> <input name="activationCode"></input></td> </tr> </table> <input type='submit' value="Activate"></input> </form> </body> </html> Hi My website was recently ftp hacked and a file inserted into it - js.php - which seems to be some sort of advertising spam programme. Having spotted the file I have renamed it to hide it but lots of other sites are still referring into my site looking for this php file. What I would like to do is to *just* open a java alert box on the referring sites to alert the users that the site has been hacked and that they should notify the webmaster so that he can fix his site. The line referring into my site is - <script type="text/javascript" src="http://www.mysite.com/js.php"></script> Is this something simple to do? I know nothing about Java or PHP so need detailed help. Thanks John As part of course work for class I must write JavaScript/XML (with CSS) to carry out the following tasks. In essence it is a micro version of twitter. Users must be able to login, make posts, edit them. A text box should appear, with reset/update buttons. When the Update button is clicked the following occurs: 1. The user name is added to the message text typed by the user 2. A time stamp is added after the message text 3. A photo is added at the left 4. Any URLs are made into hyperlinks 5. The combined photo and text, formatted suitably, is prepended to the list of previous messages below the input area, i.e. the most recent item is at the top of the places visited. 6. The message box is cleared to allow further user input. - When the Clear button is clicked the text area is cleared. Additionally 1. Using a manually created XML file users must be able to "register themselves" 2. Posts must be manually saved in an XML file which loads upon login 3. When anyone opens the default page they are presented with a list of all your journey and comments (retrieved from the server). 4. Allow a registered user who has logged in to add, delete or modify only their comments. 5. Use one or more XML files to record registered users and passwords as well as posts and comments. These are manually created in 1& 2 above. ---- I initally tackled the first section using innerHTML and other various Javascript components but am at a total loss as to how to achieve the same thing using nodes (and XML). Any help with regards with where to begin would be much appreciated. Hi there, I'm trying really hard to find the solution to this error I am getting in java. Im using blue j. I have a feeling its something other than just braces missing somewhere, I have looked carefully and I'm just having bad luck!! I cant proceed to the next stage of my code unless I get this bit perfected with no syntax errors. I really really appreciate someone helping me out. Code: import java.util.Scanner; import java.awt.Color; /** * Write a description of class stage2 here. * * @author (Gayethiri Guruthevan) * @version (Version 1.0) */ public class stage2 { public static void main(String[]args) { final int WIDTH = 500; // width of the sheet in pixels final int HEIGHT = 500; // height of the sheet in pixels int x; // the x-coordinate int y; // the y-coordinate String direction; // the direction chosen // Create a Scanner object for keyboard input. Scanner keyboard = new Scanner(System.in); // 1. Ask the user for the ant's x-coordinate System.out.print("Enter your ant's x-coordinate: "); x = keyboard.nextInt(); // 2. If the x-coordinate is outside the allowed range, // print an error message and exit if(x < 0 || x > WIDTH-1) { System.out.println("The x-coordinate must be between 0 and " + (WIDTH-1)); System.exit(-1); } // 3. Ask the user for the ant's y-coordinate System.out.print("Enter your ant's y-coordinate: "); y = keyboard.nextInt(); // 4. If the integer is outside the allowed range, // print an error message and exit if(y < 0 || y > HEIGHT-1) { System.out.println("The Y-coordinate must be between 0 and " + (HEIGHT-1)); System.exit(-1); } // 5. Ask the user for the direction System.out.print("Enter the direction the ant is facing: "); direction = keyboard.next(); System.out.print("How many steps should the ant take?: "); int numStepsToTake = keyboard.nextInt(); for(int i=0; i<numStepsToTake;i++) { if (direction.equalsIgnoreCase("DL")) { y+=1; x-=1; } else if (direction.equalsIgnoreCase("DR")) { y-=1; x+=1; } else if (direction.equalsIgnoreCase("D")) { y-=1; } if (direction.equalsIgnoreCase("U")) { x+=1; } else if (direction.equalsIgnoreCase("UR")) { y+=1; x+=1; } else if (direction.equalsIgnoreCase("UL")) { y+=1; x-=1; } else if (direction.equalsIgnoreCase("L")) { x-=1; } else if(direction.equalsIgnoreCase("R")) { x+=1; } else { System.out.println("That is incorrect please enter the right direction"); } // "Wrap" the x and y-coordinates if the ant has walked over the edge of the paper if(x < 0) { x += WIDTH; } else if(x > WIDTH-1) { x-=WIDTH; } if(y < 0) { y += HEIGHT; } else if(y > HEIGHT-1) { y-=HEIGHT; } //Here is the new method for antart. AntArt.init(WIDTH,HEIGHT,x,y); for(int i=0; i<numStepsToTake;i++) { int oldX = x; int oldY = y; Color paperColor = AntArt.getColor(x,y); antColor = nextColor(antColor,paperColor); AntArt.setColor(antColor); // Take a step direction = nextDirection(direction,antColor,paperColor); x = stepX(x,direction,WIDTH,HEIGHT); y = stepY(y,direction,WIDTH,HEIGHT); AntArt.paint(oldX,oldY); } AntArt.paint(x,y); System.out.println("The new x is " + x + " and y coordinate is " + y); } } } private static int stepx(int x, String direction, int WIDTH, int HEIGHT) { //this will be the answer int newx = x; // take a step in the right direction if(direction.equals("UR")) { newx += 1; } else if (direction.equals("R")) { newx += 1; } else if(direction.equals("DR")) { newx += 1; } else if(direction.equals("DL")) { newx -= 1; } else if(direction.equals("L")) { newx -= 1; } else if(direction.equals("UL")) { newx -= 1; } // "Wrap" the x and y-coordinates if the ant has walked over the edge of the paper if(newx < 0) { newx += WIDTH; } else if(newx > WIDTH-1) { newx -= WIDTH; } return newx; } } } private static int stepY(int y, String direction, int WIDTH, int HEIGHT) { // this will be the answer int newy = y; // take a step in the right direction if(direction.equals("UR")) { newy += 1; } else if (direction.equals("R")) { newy += 1; } else if(direction.equals("DR")) { newy += 1; } else if(direction.equals("DL")) { newy -= 1; } else if(direction.equals("L")) { newy -= 1; } else if(direction.equals("UL")) { newy -= 1; } // "Wrap" the x and y-coordinates if the ant has walked over the edge of the paper if(newy < 0) { newy += HEIGHT; } else if(newy > HEIGHT-1) { newy -= HEIGHT; } return newy; } } Hello all,I have a website and I would like a pop-up window to promote a new website venture I have. I would like for the new website to open in a completely new window/browser when my members simply click on the index page (No link or Buttons).The code below does most of what I ask lol,but it.. 1.Only opens in a new tab (in same browser) while I would like for it to open in a completely new browser "full page" menu bar scroll tab and all. plus 2.It seems to open each and every time the page is clicked,which will be annoying to my members.I would only like for it to open 1 time per visitor every 24 hours or whenever cookies are cleared. Code: <html> <head> <script type="text/javascript"> function click_on() { window.open("URL HERE", "_blank"); } </script> </head> <body onclick="click_on()"> </body> </html> I am no expert at this,and my knowledge is very limited,so excuse me if this is a simple situation.Any help would be greatly appreciated. Thanks, Roco Hi to every one. I'w created a mini javascript game for my site where you click on red button as fastest as you can for 10 seonds to achieve as best as you can click numbers per second. And the end score is a variable which I send to a function which reads the array that contains ten best scores and write your score in same array if it's among 10 best. Now I want to make somehow to save that array on server so I could read it on page load to show a high score list, but I'm having trouble to write that array in any kind of data on server that I could read it again from same data. I would be very grateful if someone can help me! I am working on my shopping cart page with DOM. In my html I created two tables one for items with add buttons, and the other one for displaying how many items are added. So, here is my html codes Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="description" content="forms" /> <meta name="keywords" content="Client Side Programming, JavaScript, CSS" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="Content-Language" content="en-us" /> <script type="text/javascript" src="shopping.js"></script> </head> <body> <h1>Central Valley Chocolates</h1> <h2>Gourmet Chocolates</h2> <table border="1" id="chocoateTrable"> <tr id="ch1"> <td>Chocolate Truffles</td><td>$34.99</td><td> <input type="button" value="Add" onclick="addItem(document.getElementById('ch1').rowIndex)" /></td></tr> <tr id="ch2"> <td>Pecan</td><td>$14.99</td><td> <input type="button" value="Add" onclick="addItem(document.getElementById('ch2').rowIndex)" /></td></tr> <tr id="ch3"> <td>Truffles</td><td>$28.99</td><td> <input type="button" value="Add" onclick="addItem(document.getElementById('ch3').rowIndex)" /></td></tr> <tr id="ch4"> <td>caramel</td><td>$22.99</td><td> <input type="button" value="Add" onclick="addItem(document.getElementById('ch4').rowIndex)" /></td></tr> <tr id="ch5"> <td>Bark</td><td>$17.99</td><td> <input type="button" value="Add" onclick="addItem(document.getElementById('ch5').rowIndex)" /></td></tr> </table> <h2>Your Shopping Cart</h2> <table id="shoppingCart" border="1"> <tr><td>Your shopping cart is empty</td></tr> </table> <p id="total"> </p> </body> </html> And in my js file, I have two functions one for adding items and the other for deleting items. Code: var emptyCart = true; var salesTotal = 0; var curRow = 1; function addItem(selectedItem){ if(emptyCart == true){ document.getElementById('shoppingCart').deleteRow(0); emptyCart = false; } var curItem = document.getElementById("chocolateTable").rows[selectedItem].cells; var selectedItem = curItem[0].innerHTML; var itemPrice = curItem[1].innerHTML; var lastItem = document.getElementById("shoppingCart").rows.length; var cartTable = document.getElementById("shoppingCart"); var newRow = cartTable.insertRow(lastItem); document.getElementById("shoppingCart").rows[lastItem].id = "R" + curRow; var itemCell = newRow.insertCell(0); itemCell.innerHTML = selectedItem; var priceCell = newRow.insertCell(1); priceCell.innerHTML = itemPrice; var actionCell = newRow.insertCell(2); actionCell.innerHTML = "<input type='button' value = 'Remove' " + "onclick=\"removeItem('R"+curROw + "')\" />"; ++curRow; salesTotal += parseFloat(itemPrice.substring(1)); document.getElementById('total').innerHTML = "<strong>Sales total</strong>: $" + salesTotal.toFixed(2); } function removeItem(rowNum){ if(document.getElementById("shoppingCart").rows.length == 1){ document.getElementById("shoppingCart").rows[0].cells[0].innerHTML = "<td>Your shopping cart is empty</td>"; document.getElementById("shoppingCart").rows[0].cells[1].innerHTML = "<td>$0.00</td>"; document.getElementById('total').innerHTML = "$" + salesTotal.toFixed(2); emptyCart = true; } else{ var selectedRow = document.getElementById(rowNum).rowIndex; var itemPrice = document.getElementById("shoppingCart").rows[selectedRow].cells[1].innerHTML; document.getElementById("ShoppingCart").deleteRow(seletedRow); salesTotal = salesTotal - parseFloat(itemPrice.substring(1)); document.getElementById('total').innerHTML = "$" + salesTotal.toFixed(2); } } However, when I click add button to add each item, I don't see anything in my shoppingCart. Anyone can tell me what is wrong with my code? Hi and hope someone can help, I'm doing some course work on setting / getting cookies for a shopping cart. It basically works except the user can only select one item of each of the goods on offer i.e. you can only buy one cup (not two), one saucer etc. etc. I've deliberately not put a quantity field on the goods selection page and was hoping to modify my set cookie function so that if you've already selected one cup, the next tiume you select a cup, cups become 2 etc. etc. Here's my set cookie function. Notice that I've hard wired a "1" in there which I want to change to the variable for the number of cups. I've also commented out some of the first few lines which were experiments to resolve the problem. Code: function setCookie(name) { alert("Thank you.\n\nYour basket has been updated."); /* if(name.value !=0 || name.value==null) name.value++; x=getCookie(name) || 0; alert(document.cookie);*/ var today = new Date(); var expiry = new Date(today.getTime()+28*24*60*60*1000); // plus 28 days document.cookie=name+"= 1 ;expires="+expiry.toGMTString(); cart = document.cookie; } My thanks, R A little while later... I've cracked it, my function now looks like this and it appears to work... Code: function setCookie(name) { alert("Thank you.\n\nYour basket has been updated."); x=parseInt(getCookie(name)) || 0; alert(x); y=x+1; var today = new Date(); var expiry = new Date(today.getTime()+28*24*60*60*1000); // plus 28 days document.cookie=name+"="+y+";expires="+expiry.toGMTString(); cart = document.cookie; } Thanks you fror your interest, appreciated, R I'm using simpleCart.js (http://simplecartjs.com ) on http://yogasports.biz and have run into issues. I would like the checkout page to allow items to be removed or quantities edited and it is currently not allowing it. The javascript is located at http://yogasports.biz/simpleCart.js Also there are additional shipping options that are not appearing upon checkout yet they are declared in the paypal account. I'm unsure of what to edit in the javascript file so that they will appear. |