M
mr_burns
hi,
i am trying to use a function that will write html into empty <span>
tags. the <span> tags will all be numbered incrementally and written
to using the same function each time. below is my javascript at the
top of the page in the <head> part:
<head>
<script>
<!--
var global_num
function fstarter () {
global_num = 1; //initiate variable as 1
}
function fwriteinside () {
getElementById('item' & global_num).innerHTML = '<p>HTML Code,
yeah!</p>';
global_num = global_num + 1; //increment var
}
-->
</script>
</body>
Below is how the empty <span> tags will be writen:
<body onLoad="fstarter()">
<span onClick="fwriteinside();" style="cursor: hand;">Add HTML</span>
<span id="item1"></span>
<span id="item2"></span>
<span id="item3"></span>
</body>
When the function, fwriteinside, is called it will write to the next
span. this way the function is alot more efficient and expandable (can
keep adding new <span> tag slots). unfortunately it isnt working as im
not sure how you would correctly do this. any help would be great.
cheers
burnsy
i am trying to use a function that will write html into empty <span>
tags. the <span> tags will all be numbered incrementally and written
to using the same function each time. below is my javascript at the
top of the page in the <head> part:
<head>
<script>
<!--
var global_num
function fstarter () {
global_num = 1; //initiate variable as 1
}
function fwriteinside () {
getElementById('item' & global_num).innerHTML = '<p>HTML Code,
yeah!</p>';
global_num = global_num + 1; //increment var
}
-->
</script>
</body>
Below is how the empty <span> tags will be writen:
<body onLoad="fstarter()">
<span onClick="fwriteinside();" style="cursor: hand;">Add HTML</span>
<span id="item1"></span>
<span id="item2"></span>
<span id="item3"></span>
</body>
When the function, fwriteinside, is called it will write to the next
span. this way the function is alot more efficient and expandable (can
keep adding new <span> tag slots). unfortunately it isnt working as im
not sure how you would correctly do this. any help would be great.
cheers
burnsy