javascript - why won't my appendChild work? -


function purchase() {     var r=document.createelement('div');     r.classname="row";     alert(r);     var p=document.createelement('div');     p.classname="purchase-hero-unit";     alert(p);     var span1=document.createelement('div');     span1.classname="span3";     span1.textcontent="&nbsp";     alert(span1);     var span2=document.createelement('div');     span2.classname="span6";     alert(span2);     var span3=document.createelement('div');     span3.classname="span3";     span3.textcontent="&nbsp";     alert(span3);     var price=document.getelementbyid('pprice').value;     var name=document.getelementbyid('pname').value;     var s=": $";     var h=document.createelement('h3');     h.textcontent=price+s+name;     alert(h);     p.appendchild(h);     span2.appendchild(p);     r.appendchild(span1);     r.appendchild(span2);     r.appendchild(span3);     var d=document.getelementbyid('spendingcontainer');     d.appendchild(r);     alert(d); } 

this function append 2 text box's input twitter bootstrap hero-unit. spendingcontainer container, __-hero-unit hero-unit. if can fix it, appreciated. thank you.

jsfiddle outputs:

{"error": "shell form not validate{'html_initial_name': u'initial-js_lib', 'form': <mooshell.forms.shellform object @ 0xa69168c>, 'html_name': 'js_lib', 'html_initial_id': u'initial-id_js_lib', 'label': u'js lib', 'field': <django.forms.models.modelchoicefield object @ 0xa6912ec>, 'help_text': '', 'name': 'js_lib'}{'html_initial_name': u'initial-js_wrap', 'form': <mooshell.forms.shellform object @ 0xa69168c>, 'html_name': 'js_wrap', 'html_initial_id': u'initial-id_js_wrap', 'label': u'js wrap', 'field': <django.forms.fields.typedchoicefield object @ 0xa69128c>, 'help_text': '', 'name': 'js_wrap'}"} 

my console says:

[18:03:21.744] referenceerror: reference undefined property a[o] @ http://html5shim.googlecode.com/svn/trunk/html5.js:5 

and:

[18:03:21.744] typeerror: variable b redeclares argument @ http://html5shim.googlecode.com/svn/trunk/html5.js:9 

these lines @ fault:

p.innerhtml=h; span2.innerhtml=p; r.innerhtml=span1+span2+span3; 

innerhtml contains html strings, not elements. need use appendchild there, too:

p.appendchild(h); span2.appendchild(p); r.appendchild(span1); r.appendchild(span2); r.appendchild(span3); 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -