PDA

View Full Version : How to add HTML to website using JavaScript


mdamon
11-19-2009, 09:10 PM
1) Project Details: (be as specific as possible):

I have an auto dealer website with 200 vehicles on it, I would like to add html content to certain vehicle models based on an if condition. For example:

If the vehicle model is Focus then add this block of HTML or a div full of html, text and whatever.

I have tried several ways like using document.write, but it does not always let me use a lot of HTML. I have sections that I want to add such as youTube videos, rebates and incentive information and iFrames that I want to display if the condition is true.

I do not want to just hide the div and then make it visible if true, this would bloat my website with a lot of information that is not needed. For example, I don't need information on F-150s hidden on the Focus page.

Im looking for an easy efficient way to do this, please let me know if you can help. i know how to do if statements, I just don't know how to add content with HTML code in it.

2) Payment Amount: $25.00

3) Payment method/ details (Paypal, check? Timeline?): Paypal

Rebbu
11-20-2009, 12:37 AM
I can do this if you want. I'll set up a pretty simple to follow template, or implement the whole thing if you want for only $10USD. PM if you are interested.

hdewantara
11-23-2009, 09:12 AM
I think document.write() would let you write a lot of HTML,
although it is also true that your page could be messy.

You could use innerHTML approach which is more neat.
Changes to the target page could always be coded somewhere else
in script file.

Regards,
HEndra D.

cyrus709
11-23-2009, 01:40 PM
I would definately go with inner html here, getElementByTagName