javascript for locating all divs and replacing with inner HTML

I have various numbers of advertisements on a page.

Each advertisement refers to the Campaign_ID (placeholder that indicates the type of ad to put here).

text text text text bla text text
<div id="AdbinControl_ID_2243"></div>
text text text text bla text text
<div id="AdbinControl_ID_2243"></div>
text text text text bla text text
<div id="AdbinControl_ID_2243"></div>

Sometimes there are 2 ads and up to 5 ads, depending on the length of the article. 2243 refers to a 300 x 217 image that goes in the body of topic X blog pages

I am looking to create a single javascript that will read through all the ads, know there are 2, 3, 4, 5... ads in the page and send this request out.

eg currently works:
<SCRIPT LANGUAGE='JavaScript'>var AdbinControl_ID=2135; </SCRIPT>
<script type="text/javascript" src="http://www.web.com/CreateAd.js"></script>

But each call is taking time... especially when there are 10 small ads to create on the page.

I was thinking, I would like to do a single call at the bottom, then just replace each on with an innerHTML. (AdbinControl_ID_2243[0], AdbinControl_ID_2243[1]...?)

eg:
document.getElementById('AdbinControl_ID_2243').innerHTML = document.getElementById('AdbinControl_ID_2243_AD').innerHTML;
(but this only works for one at a time, not a group of the same ad_id)

I can modify the DIV tag that is dropped or whatever will make this easier.

Thanks!
amakaramAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
First problem
<div id="AdbinControl_ID_2243"></div>
text text text text bla text text
<div id="AdbinControl_ID_2243"></div>
text text text text bla text text
<div id="AdbinControl_ID_2243"></div>

Open in new window

ID's must be unique - you cannot have duplicate ID's on a page (... you can but then things won't work as expected) - html specification says id's are unique.

So that is your first problem.

Secondly, can you better explain what you are trying to do? I am not clear on what is required from your explanation - what is being set when you set the innerHTML, what calls are taking a long time.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
amakaramAuthor Commented:
Good point.

*Yes, these questions are now almost the same. Originally it WAS two different directions.
0
amakaramAuthor Commented:
This was about looping through the same id's using an array ([0], [1]...), which is not possible.
The other was creating the java for finding and looping through classes, getting id's ...
These were the differences.
0
Julian HansenCommented:
Ok - can you post back to the other thread what exactly you still need.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.