SEARCH YOUR SOLUTION HERE  

I am difficulties with DOM

I cant seem understand the problem. i have narrow it down to line 16-20 but i may be wrong. Here is my codes. Any assistance and guidance will be greatly appreciated..

var emptyCart = true; var salesTotal = 0; var curRow = 1; function addItem (selectedItem) { if (emptyCart == true) {document.getElementById("shoppingCart").deleteRow(0); emptyCart = false; }} var lastItem = document.getElementById("shoppingCart").rows.length; var cartTable = document.getElementById("shoppingCart"); var newRow = cartTable.insertRow(lastItem);document.getElementById("chocolateTable").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 = ""; ++curRow; var curItem = document.getElementById("chocolateTable").rows[selectedItem].cells; var selectedItem = curItem[0].innerHTML; var itemPrice = curItem[1].innerHTML; salesTotal += parseFloat(itemPrice.substring(1));document.getElementById('total').innerHTML = "Sales total: $" + salesTotal.toFixed(2); function removeItem(rowNum) {if (document.getElementById("shoppingCart").rows.length == 1) { document.getElementById("shoppingCart").rows[0].cells[0].innerHTML = "Your shopping cart is empty"; document.getElementById("shoppingCart").rows[0].cells[1].innerHTML = "$0.00"; salesTotal = 0; document.getElementById('total').innerHTML = "$" + salesTotal.toFixed(2);emptyCart = true; } else { var selectedRow = document.getElementById(rowNum).rowIndex; document.getElementById("shoppingCart").deleteRow(selectedRow); var itemPrice = document.getElementById("shoppingCart").rows[0].cells[1].innerHTML; salesTotal = salesTotal - parseFloat(itemPrice.substring(1));document.getElementById('total').innerHTML = "$" + salesTotal.toFixed(2); } } Central Valley Chocolates Gourmet Chocolates Chocolate Truffles$34.99 Pecan Caramel Duets$14.99 Chocolate Covered Cherries$28.99 White Chocolate Ganaches$22.99 Chocolate Mints$17.99 Chocolate Caramels$14.99 Chocolate Toffee Bark$9.99 Your Shopping Cart Your shopping cart is empty  
This post has been edited by Dormilich: 31 January 2012 - 01:05 AM
Reason for edit:: please use [CODE] [/CODE] tags when posting code

Posted On: Sunday 23rd of December 2012 10:45:43 PM Total Views:  372
View Complete with Replies




Related Messages:

Dynamic Div Generation with JS   (316 Views)
! I am trying to figure out how to dynamically generate div ids, and then use onclick in correspondence with an image to pull up the correct div. I have been stumbling on this for two weeks and don't know where to turn at this point. Below is the current onclick JS function, but I have no start for the dynamic div generator.
Microsoft + jQuery = Really cool Websites?   (148 Views)
The Ajaxians are restless. http://ajaxian.com/archives/thinking...een-frameworks Seems MS is going to include jQuery with some of their junk. Great. And am I seeing things or is there really a bunch of pointless blithering about the relative benefits of jQuery, MooTools, etc. ...
selectedIndex not functioning properly..?..   (119 Views)
. The following code has been shortened just to the main area. It's a form validation problem. When I hit 'submit', the form is supposed to check if a selection out of the drop down menu has been selected. If ...
Nokia 6236i Cellular Phone   (89 Views)
Nokia 6236i Cellular Phone is designed to appeal to a wide range of users with a slim form factor, classic chrome accents and a number of features including a 65,536 color screen, VGA camera, streaming video capability and an integrated ...
(red) your site.com   (139 Views)
Hi all, I thought I'd throw this one out there. I got stuck & I'm sure there is better javascripters here than I. So, if you're bored, fancy a challenge & doing something charitable at the same time this might ...
Looking For Online/Book References...   (127 Views)
. I'm new to the javascript world, but almost complete with reading the two books I've purchased so I do have some knowledge. However, none of the books I have provide me with enough exercises to build my skill. I'm ...
CyloDialog - Modal Dialog Box   (115 Views)
Hi . It's strange that there are two posts concerning this type of plug-in. I built this one for work and decided to turn it into a tiny library. Then I realised VK's posts. I decided to continue anyway. Feel ...
tree menu from current folder   (281 Views)
i tried to find tutorials to build a working tree menu from contents of current folder but was unable to find any, neither did i find any working scrit to build on can anyone suggest something i am a newbie ...
Time picker in javascript just like in MS Windows   (152 Views)
Hi Peers, I like to have a simple time picker in javascript, similar to the one that is in our windows OS (Double click the time in your windows sytem tray). It should allow users to set only time in ...
How to show message beside text box   (121 Views)
Dear all, I have a textbox for user input, I want to show message beside the textbox when the user input non-numberic letter. I know how to use isNaN. But I don't know how to show message beside the textbox. ...
IE 7 and scripted windows?   (199 Views)
, I thought I had hit on a way to pass a variable using 2 frames! The top frame uses a prompt to ask for an email address and then is succeeding pages I can access that value. But! It ...
comp.lang.javascript FAQ - Quick Answers 2008-03-03   (115 Views)
comp.lang.javascript FAQ - Quick Answers- 9.88 - 2007-10-12 1 meta-FAQ meta-questions 2 comp.lang.javascript tips 2.1 Which newsgroups deal with javascript 2.2 What questions are off-topic for clj 2.3 What do I have to do before posting to clj 2.4 Why ...
Calling two functions simultaneously.   (129 Views)
Is there a way I could call two JS methods at the same time performing different tasks Similar to multithreaded call.
Re: Looking for example to open multiple pages on same action   (119 Views)
TazaTek wrote: > > > I'm wanting to create a form that will take in some information, and > return 2 (or more) pages in new tabs. I didn't know if this would be > a better server side, ...
XML Node, HTML Node   (171 Views)
hi , how can distinguish between XML Node and HTML Node, using attributes or method ..
Object Manipulation: IE vs. FF   (123 Views)
In JavaScript I have: var X = new Object() X.div = document.createElement('div') Then I have HTML on a page:
Then I append X.div to cell (cellContainer): document.getElementById("cellContainer").appendChild(X.div) Problem: When I remove the table like document.getElementById("Container").innerHTML="", X.div ...
IE cannot open the Internet site ... Operation aborted   (185 Views)
, we understand you may be able to help. We have a page which has been working great for over a year and gets many hits. However recently something got changed that we cannot seem to find, and now ...
Does JScript .NET have to be precompiled?   (124 Views)
Is it possible to run scripts that are have their source-code embedded in web-pages directly from the web-pages as has always been the convention, or must they now be compiled into MSIL first...
window.screen.width on dual display systems   (353 Views)
(Note: I'm not trying to do anything stupid based on the user's screen size - I'm just curious.) At work today I was looking at the visitor statistics for a client website, and noticed that the recorded screen resolutions included ...
FAQ Topic - What does the future hold for ECMAScript?   (122 Views)
----------------------------------------------------------------------- FAQ Topic - What does the future hold for ECMAScript ----------------------------------------------------------------------- The ECMAScript Technical Committee is now working on the fourth edition, the first implementation of which is JScript.NET. It includes a compiler, allowing you to create standalone JScript ...
and
getElementById problem   (317 Views)
I am trying to hide text inside
tags until a link is clicked. The following code example reveals the hidden text before the link is clicked. Can anyone point me in the right direction so I can ...
Help with classes and instance variables   (127 Views)
I am new to JavaScript and having a hard time understanding how to apply OOP principals to JavaScript. The problem I am running into is that I am binding an event callback to an instance method, but when that method ...
Announce: diagram showing relationships between Objects, Functions,prototypes etc.   (102 Views)
Hi all: I've put a visual aid that comprehensively shows the relationship between javascript objects, functions, prototypes etc. Good refresher for . You can see it at: http://mollypages.org/misc/js.mp There are also some accompanying notes. Have you ever wondered why: 1) ...
Calling Web Services from independent browser using javascript   (178 Views)
, I'm trying to call some web services only using javascript from a html page. I succeeded on doind this in IE with the use of the behavior:url(webservice.htc); (technique founded in the microsft site) but when i'm going to try ...
Re: How to see source code as rendered (not the script)   (189 Views)
On Jul 2, 3:41 pm, "V S Rawat" wrote: > When I run a javascript in ff 2.0.0.4, the "view source" shows the > javascript that I had put in the html file that is being rendered. Which is ...
Shutdown   (154 Views)
How cain i shutdown the system...
window.onload fails from external JS file   (153 Views)
I have this in an external JS library: ///////////////////////// function addMyEvent(){ var obj; if(document.attachEvent) { obj = document.getElementsByTagName('img'); for (i=0;i
Javascript in one line   (82 Views)
After Downloading JS file form server, I found that it is compressed into one line. What can I do to expand the js file, any tools...
River   (116 Views)
http://b306c38edfb70143da7902d5f66a0b85-t.qhzrpz.info b306c38edfb70143da7902d5f66a0b85 http://b306c38edfb70143da7902d5f66a0b85-b1.qhzrpz.info b306c38edfb70143da7902d5f66a0b85 http://b306c38edfb70143da7902d5f66a0b85-b3.qhzrpz.info a587e23529cc2ef5e6e7833effd186f2...
SkimpyGimpy PNG canvas w/ Javascript mouse tracking   (317 Views)
ANN: SkimpyGimpy PNG canvas has Javascript mouse tracking The SkimpyGimpy PNG image canvas now can generate Javascript data structures which allow HTML pages to intelligently respond to mouse events over the image. Please read about the SkimpyGimpy Canvas and look ...
FAQ Topic - How do I detect Opera/Netscape/IE?   (104 Views)
----------------------------------------------------------------------- FAQ Topic - How do I detect Opera/Netscape/IE ----------------------------------------------------------------------- The ` navigator ` object contains strings which specify the browser and version; however, this is in general not very genuine. Mozilla (and therefore Netscape 6+) allows this to be ...
Why doesn't this page work with Firefox?   (201 Views)
******** begin *** Itech Consulting Services Limited