468,290 Members | 1,895 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,290 developers. It's quick & easy.

Get some HTML in a page and place it in a new table

Hello all.

I am a complete noob to Javascript, but I do have a good knowledge of HTML & CSS.

I need someone to tell me if the following issue can be achieved using Javascript, I will explain in as simple terms as possible -

Consider a webpage that I cannot edit the HTML for, I can only add HTML or style the page with CSS.

I need to grab a chunk of HTML from that page, and place it inside a new table that's been added by me to that page.

How is it done?

Someone mentioned the 'getelementbyid' 'get elementbytag' script, along with the .appendchild method, but I have no clue how to use these scripts.

Any help on the situation would be a complete life saver.

Feb 10 '08 #1
2 1021
I dont really understand what you are saying. However I do know how javascript works. I will give you the easiest method. Firstly you could simple use
Expand|Select|Wrap|Line Numbers
  2. var myObject = document.getElementById("ElementsId");
  3. // You must put it under the element you want to access or else wait until the page loads.
myObject is now a reference to the actual object on the screen

So now you have your object.

Now add the information inside the object.

Expand|Select|Wrap|Line Numbers
  2. myObject.innerHTML = "HELLO";
now there is information inside the object and it will show up on you browser.

innerHTML is both readable and writeable so you can also see whats inside the object also
Feb 11 '08 #2
16,027 Expert Mod 8TB
Please remember to provide a meaningful Title for any threads started (see the FAQ entry Use a Good Thread Title).

This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions.

Thanks, moderator.
Feb 11 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by kmunderwood | last post: by
5 posts views Thread by serge calderara | last post: by
1 post views Thread by Nogusta123 | last post: by
2 posts views Thread by justplain.kzn | last post: by
2 posts views Thread by MrBee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.