Book Section
-----
TY JavaScript 3rd Ed.
Teach Yourself JS 1.5
Teach Yourself DHTML
Teach Yourself JS 1.3
LLWW: JavaScript

General Section
-----
Discussion Forum
Articles / Tips
JavaScript Links
About the Author
Privacy Policy
Contact Me



Other Sites
-----
Website Workshop
JavaScript Weblog

JavaScript Workshop Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
ONCLICK CREATEELEMENT INSERTROW

 
Post new topic   Reply to topic    JSWorkshop Forum Index -> DHTML and CSS
View previous topic :: View next topic  
Author Message
Heinz
New member
New member


Joined: 17 Nov 2009
Posts: 4
Location: RIBERAS DEL PILAR,CHAPALA, JALISCO,MEXICO

PostPosted: Tue Nov 17, 2009 4:22 pm    Post subject: ONCLICK CREATEELEMENT INSERTROW Reply with quote

HEY GUYS,
I'M WORKING ON SOMETHING SIMILAR BUT WITH MULTIPLE FORMS IN 'DISPLAY' FRAME INSERTING ROW TO 'CARTBODY' IN 'REGISTER' FRAME. THE SCRIPT IS RUNNING FROM A SEPERATE JS FILE LINKED TO THE DOCUMENT IN THE 'DISPLAY' FRAME. SOME HOW I'M NOT GETTING THE VALUES FROM THE 'CARTITEM' FORM TO APPEAR IN THE ROW. THE ROW SHOWS UP BUT MINUS THE TD DATA.


Code:

function addtocart(cartbody, cells){
var carttable = top.frames['register'].document.getElementById('carttable');
var cartbody = top.frames['register'].document.getElementById('cartbody');
var cartitems=document.getElementsByClassName('cartitem');
for(var i = 0; i <cartitems.length; i++)
var cartitem=cartitems[i].elements.length;

var itemrow=top.frames['register'].document.createElement('tr');
itemrow.setAttribute('id','itemrow');
itemrow.setAttribute('className','itemrow');

var addcode=top.frames['register'].document.createElement('td');
addcode.setAttribute('id','code');
addcode.setAttribute('colspan','1');
addcode.setAttribute('value','this.cartitem.code.value');

var additem=top.frames['register'].document.createElement('td');
additem.setAttribute('id','item');
additem.setAttribute('colspan','1');
additem.setAttribute('value','this.cartitem.item.value');

var addcolor=top.frames['register'].document.createElement('td');
addcolor.setAttribute('id','color');
addcolor.setAttribute('colspan','1');
addcolor.setAttribute('value','this.cartitem.color.value');

var addsize=top.frames['register'].document.createElement('td');
addsize.setAttribute('id','size');
addsize.setAttribute('colspan','1');
addsize.setAttribute('value','this.cartitem.size.value');

var addprice=top.frames['register'].document.createElement('td');
addprice.setAttribute('id','price');
addprice.setAttribute('className','price');
addsize.setAttribute('colspan','1');
addprice.setAttribute('value','this.cartitem.price.value');

var addquantity=top.frames['register'].document.createElement('td');
addquantity.setAttribute('id','quantity');
addquantity.setAttribute('className','quantity');
addquantity.setAttribute('colspan','1');
addquantity.setAttribute('value','this.cartitem.quantity.value');

var addcost=top.frames['register'].document.createElement('td');
addcost.setAttribute('id','cost');
addcost.setAttribute('className','cost');
addcost.setAttribute('colspan','1');
addcost.setAttribute('value','this.cartitem.quantity.value*this.cartitem.price.value');
addcost.setAttribute('value','toFixed(2)');

var addtotal=top.frames['register'].document.createElement('td');
addtotal.setAttribute('id','total');
addtotal.setAttribute('className','col2');
addtotal.setAttribute('colspan','1');
addtotal.setAttribute('value','subtotal.value');
addtotal.setAttribute('value','toFixed(2)');

var addclear=top.frames['register'].document.createElement('td');
addclear.setAttribute('id','clear');
addclear.setAttribute('colsan','1');
addclear.setAttribute('align','center');

var addremoveitem=top.frames['register'].document.createElement('a');
addremoveitem.setAttribute('id','removeitem');
addremoveitem.setAttribute('className','removeitem');
addremoveitem.setAttribute('title','Remove this item');
addremoveitem.setAttribute('innerTEXT','[x]');

addclear.appendChild(addremoveitem);

itemrow.appendChild(addcode);
itemrow.appendChild(additem);
itemrow.appendChild(addcolor);
itemrow.appendChild(addsize);
itemrow.appendChild(addprice);
itemrow.appendChild(addquantity);
itemrow.appendChild(addcost);
itemrow.appendChild(addtotal);
itemrow.appendChild(addclear);
cartbody.appendChild(itemrow);
}

[img] Sad [/img]
NO HECKLING FROM THE PEANUT GALLERY PLEASE. I'M GUESSING YOU CAN TELL MY JS IS HORRIFIC AND I'VE BEEN WORKING ON THIS FOR TWO MONTHSSSSSS!
ANY ASSISTANCE WILL BE GREATLY APPRECIATED
Back to top
View user's profile Send private message
phil karras
Senior Member
Senior Member


Joined: 15 Jul 2002
Posts: 1776
Location: MD

PostPosted: Tue Jul 17, 2012 5:32 am    Post subject: Reply with quote

Read my article on how to send data between frames:

Hints on passing data between windows or frames (added 8/28/2002)
http://www.jsworkshop.com/bb/viewtopic.php?t=152
_________________
Phil K
Circle Software Consulting
Test website: http://cs.yrex.com/
Guidelines for Posting: http://www.jsworkshop.com/posting.html
IHBAAA = It Has Been Asked And Answered
KISS: http://www.jsworkshop.com/bb/viewtopic.php?t=508
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    JSWorkshop Forum Index -> DHTML and CSS All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
(c) 1997-2002 Starling Technologies and Michael Moncur. Portions (c) Sams Publishing.