Jump to content
MakeWebGames

Javascript help (Greasemonkey Script)


aha2095

Recommended Posts

I'm extremely bad with javascript so I need help getting information from a HTML table that is in an iframe and turning it into a variable.

The frame is opened with JS if that could affect it.

Thankies for taking the time to read this post!

Link to comment
Share on other sites

Hmmmm, if i remember correctly you can get the contents of a Frame/iFrame with window.frames..

I am going to assume the iframe has an ID of "myIframe", in the iFrame is a form with an id of "myForm" and a hidden input with the id "myInput"..

I cannot guarantee this will work, but try this..

 

var myValue = window.frames['myIframe'].document.forms['myForm'].elements['myInput'].value

 

And of course you should be able to set a value within an iFrame too.

 

window.frames['myIframe'].document.forms['myForm'].elements['myInput'].value = "Boobies";

 

Give that a try. :thumbup:

Link to comment
Share on other sites

Ok, I'm confused now I thought it was in an iframe as it's the way it was always done but its just the pages being loaded with javascript on click I think (I did say I'm bad with JS right?).

So I just need to get information from a HTML table and turn it into a variable.

Link to comment
Share on other sites

Okay, well the table's <td> will need ID's if you want to get the value from it.

 

<table><tr><td id="td1">Meh Value!</td></tr></table>

 

Using the ID, you can get the value as such;

 

<script type="text/javascript">
   // Get the value
   var val = document.getElementById('td1').innerHTML; // Meh Value!

   // Change the value
   document.getElementById('td1').innerHTML = 'Meh new value!';
</script>
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...