/    Sign up×
Community /Pin to ProfileBookmark

getElementById innerHTML not working

Hello,
I have 14 products with different model numbers and descriptions in a table. (I’ve only illustrated two here)
The way it is supposed to work is that when you click on each swatch graphic it changes the pic (and all the info) to that specific handbag but for some reason I can’t get the product code inner html to work on this second table.

Can someone take a look at this and tell me what I am missing please?

[CODE]<div id=”valenciacontent”><!– InstanceBeginEditable name=”Valencia Content Area” –>
<table width=”780″ height=”600″ border=”0″ align=”center” cellpadding=”0″ cellspacing=”0″ bgcolor=”#FFFFFF”>
<tr>
<td valign=”top”>

<table width=”425″ border=”0″ cellspacing=”15″ cellpadding=”0″>
<tr>
<td height=”350″><img name=”Valenciaimage” border=”1″ IMG SRC=”http://www.lexingtongardens.com/shopsite_sc/media/ladies/handbags/baggallini/grv409_1.gif” ></td>
</tr>

<tr>
<td><table width=”425″ border=”0″ cellpadding=”0″ cellspacing=”11″><td width=”25″><img src=”http://www.lexingtongardens.com/shopsite_sc/media/ladies/handbags/baggallini/25px_spacer.gif” width=”25″ height=”5″></td>

<td HREF=”javascript:void(0)” onclick=”Valenciaimage.src=’media/ladies/handbags/baggallini/valencia/bvg409tmsm.jpg’;shop5.href=’http://lexingtongardens.com/shopsite_sc/valencia.html#g409tm’; link.src=’http://www.lexingtongardens.com/shopsite_sc/media/ladies/handbags/baggallini/purchase_online.jpg’; document.getElementById(‘color5′).innerHTML=’Crinkle:Tomato/Mango (Gold Hardware)’;
document.getElementById(‘price5′).innerHTML=’$ 114.95’;
document.getElementById(‘pc5′).innerHTML=’VALG409′; ” width=”25″>
<img src=”media/ladies/handbags/baggallini/valencia/tomato_mango_g.gif” width=”25″ height=”25″>

<td HREF=”javascript:void(0)” onclick=”Valenciaimage.src=’media/ladies/handbags/baggallini/valencia/bvs410tmsm.jpg’;shop5.href=’http://lexingtongardens.com/shopsite_sc/valencia.html#s410tm’; link.src=’http://www.lexingtongardens.com/shopsite_sc/media/ladies/handbags/baggallini/purchase_online.jpg’; document.getElementById(‘color5′).innerHTML=’Crinkle:Tomato/Mango (Silver Hardware)’;
document.getElementById(‘price5′).innerHTML=’$ 114.95’;
document.getElementById(‘pc5′).innerHTML=’VALS410’; ” width=”25″>
<img src=”media/ladies/handbags/baggallini/valencia/tomato_mango_s.gif” width=”25″ height=”25″><td width=”25″>

<img src=”http://www.lexingtongardens.com/shopsite_sc/media/ladies/handbags/baggallini/25px_spacer.gif” width=”25″ height=”5″></td></table>
</td>
</tr>

<tr><td class=”bodycopy”><b>Click on swatch to view item in that color</b></td></tr>

<tr><td><table align=”left” width=”425″ border=”0″ cellspacing=”0″ cellpadding=”0″>

<tr><td width=”400″ align=”left”><span class=”baggallininame”>FABRIC & COLOR:</span>
<span id=”color5″ class=”bodycopy” >Crinkle has 14 single colors or color combos to choose from.</span></td></tr>

<tr><td align=”left”><span class=”baggallininame”>DIMENSIONS:</span>
<span class=”bodycopy”>11″ x 16.5″ x 6″</span></td></tr>

<tr><td align=”left”><span class=”baggallininame”>PRICE:</span>
<span class=”bodycopy”>$114.95</span></td></tr>

<tr><td align=”left”><span class=”baggallininame”>WEIGHT:</span>
<span class=”bodycopy”>1.6 lbs.</span></td></tr>

<tr><td align=”left”><span class=”baggallininame”>PRODUCT CODE:</span>
<span id=”pc5″ class=”bodycopy” >VALG409, VALS410</span>
</td></tr>
</table>
</td>
</tr>
</table>[/CODE]

Not a JS coder so once again I’m confused.
Thanks so much

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisJun 02.2009 — I get:Error:'shop5' is undefined
Copy linkTweet thisAlerts:
@zwackauthorJun 02.2009 — Gil,

Thanks for the response. I know very little about this language. Can you tell me or show me what (and or where) I need to write to define it so that it will work like the other id's pulling the separate inner html in when clicked?
Copy linkTweet thisAlerts:
@gil_davisJun 02.2009 — What is it supposed to be? Is there some HTML that has a HREF attribute that you want to change according to which swatch is clicked?
Copy linkTweet thisAlerts:
@zwackauthorJun 02.2009 — Gil,

If I could trouble you to look at this page:

http://lexingtongardens.com/shopsite_sc/ss/preview.cgi?&ran1=171&ran2=144&page=251

When you click on a swatch icon the product switches to that specific model and the ensuing text (inner html, etc) changes to reflect that.

I have it working on this page example in that one table but when I find and replace the next product numbers and graphics (illustrated in my code example) it seems that I must be hosing something as the PC id is no longer working as intended.

Thanks again.
Copy linkTweet thisAlerts:
@zwackauthorJun 04.2009 — I don't know of any other way to describe what I am trying to do other than to point to the page that the javascript is working in that table only.

I want the innerhtml to change and reflect the id's selected...?

When you click on a swatch the picture changes to that particular product and the text changes to reflect that products detail.....

I have it working on the page link provided but it isn't working in the tables with the code I provided here.

Any help would be appreciated but I don't know javascript and merely cut and pasted the code snipped from the mfg website replacing the specific file paths etc to our own.

Thanks.
×

Success!

Help @zwack spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...