Dark Bit Factory & Gravity
ARCHIVE => Archive => Java,JS & Flash => Topic started by: Xone on October 18, 2008
-
Hey all,
I'm having some difficulty getting a variable to display on a webpage.
I have strings working, but not values ???
Inside the JAVA -
var MyVariable = 1
document.getElementById("IDhere").innerHTML="The variable is "+MyVariable+" ";
Inside the HTML -<div id="IDhere"> </div>
The firebug debugger in firefox 3 is reporting the error as 'getElementById is Null'.
What am I missing ?
-
A semi-colon?
var MyVariable = 1 ;
-
missed that in the example above :) But no, they all have semi-colons in the main code SW.
This is why I'm confused. I'm sure I've covered everything, and i've been trying to find the problem
for a few days now.
Maybe the innerhtml isn't the fault, maybe there's something wrong with the getElementById part.
-
I might be barking up the wrong tree here but I thought that innerhtml was used to alter the text or the html in a page..
By it's nature surely it uses strings?
<script type="text/javascript">
function changenumber(){
document.getElementById('IDhere').innerHTML = '2';
}
</script>
<div id='IDhere'>1</div>
<input type='button' onclick='changenumber()' value='CHANGE NUMBER'/>
??
I don't really understand what you're trying to do here sorry.
-
The webpage (which is a few years old now) used to relay variable data (per second) from the javascript to webpage
using document.all, but since document.all is no longer valid, I have to updated the webpage to use the
getElementById command instead.
The aim is to get the values to display on the webpage in the Firefox 3 browser.
I'm using it for both text and values. As far as I know, values should be possible.
I can't send it as a string shockwave, it has to be a changeable variable because of the frequency it's being updated.
Update:
Problem has finally been solved :||