View Full Version : Syntax problems with breaking up html statement in javascript

01-28-2009, 03:33 PM
I can't seem to get an image to appear and I know it is because I can't break up this statement right the images are saved as ad1, ad2 etc. and it is supposed to come up with a random image managed to get it to work last night but then I left my memory stick and it is due today. Basically I can't get the quotation marks right.

document.write('<a href="rLink"><img source= "ad'+rNumber+'.js" alt="rAd"/></a>')


Philip M
01-28-2009, 03:44 PM
document.write('<a href="rLink"><img src= ad" + rNumber + ".js" alt="rAd"/></a>')

01-28-2009, 03:50 PM
ya that didn't work

01-28-2009, 04:16 PM
ya that didn't work

well his code is correct, so maybe thats not the issue, can you post more of your script?

Philip M
01-28-2009, 06:04 PM
ya that didn't work

"How sharper than a serpent's tooth it is to have a thankless child! Away, away!" Shakespeare's 'King Lear', 1605

01-28-2009, 06:23 PM
document.write('<a href="rLink"><img src= "ad'+rNumber+'.js" alt="rAd"/></a>')

Should be src. That's the only error I can see. The reason Philips doesn't work is because it seems he didn't notice you're using single quotes and is using " to + the statements together. Your example was right in the first place. Just the source part needed changing.