Lost reference to control/div

L

Lloyd Sheen

I am having a bad Javascript day.

I am using the following code (at the end of the post) to obtain a div and
then populate it with some text for debugging purposes.

On the first time thru the variable nowplay is found and is populated. For
every event after that the getElementById returns null.

Please help.

Thanks

Lloyd Sheen


The div code is as follows:

<td style="text-align: center;" colspan="2" valign="middle"
<object id="AUDIOFILES"
classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"
type="application/x-oleobject"
width="320" height="62">
<param name="URL" value="" />
<param name="AutoSize" value="true" />
<param name="ShowAudioControls" value="true" />
<param name="ShowDisplay" value="false" />
<param name="Enabled" value="True" />
<param name="AutoStart" value="true" />
<param name="PlayCount" value="0" />
<param name="Volume" value="75" />
<param name="balance" value="0" />
<param name="Rate" value="1.0" />
<param name="Mute" value="False" />
<param name="fullScreen" value="False" />
<param name="ShowStatusBar" value="True" />
</object>
<div id="CurrentStatus" >
</div>
</td>


<script type="text/javascript" for="AUDIOFILES"
event="playStateChange(NewState)">

var test;
var nowplay;
var player;

nowplay=document.getElementById('CurrentStatus');
if (nowplay==null)
debugger;

switch (NewState)
{
case 1:
break;
case 2:
break;
case 3:
break;
case 8:
playAudio("Nothing");
break;
default:
break;
}
if (nowplay!=null)
{
nowplay.outerText=NewState;
}

</script>
 
L

Lloyd Sheen

Nevermind, got it.


Lloyd Sheen said:
I am having a bad Javascript day.

I am using the following code (at the end of the post) to obtain a div and
then populate it with some text for debugging purposes.

On the first time thru the variable nowplay is found and is populated.
For every event after that the getElementById returns null.

Please help.

Thanks

Lloyd Sheen


The div code is as follows:

<td style="text-align: center;" colspan="2" valign="middle"
<object id="AUDIOFILES"
classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"
type="application/x-oleobject"
width="320" height="62">
<param name="URL" value="" />
<param name="AutoSize" value="true" />
<param name="ShowAudioControls" value="true" />
<param name="ShowDisplay" value="false" />
<param name="Enabled" value="True" />
<param name="AutoStart" value="true" />
<param name="PlayCount" value="0" />
<param name="Volume" value="75" />
<param name="balance" value="0" />
<param name="Rate" value="1.0" />
<param name="Mute" value="False" />
<param name="fullScreen" value="False" />
<param name="ShowStatusBar" value="True" />
</object>
<div id="CurrentStatus" >
</div>
</td>


<script type="text/javascript" for="AUDIOFILES"
event="playStateChange(NewState)">

var test;
var nowplay;
var player;

nowplay=document.getElementById('CurrentStatus');
if (nowplay==null)
debugger;

switch (NewState)
{
case 1:
break;
case 2:
break;
case 3:
break;
case 8:
playAudio("Nothing");
break;
default:
break;
}
if (nowplay!=null)
{
nowplay.outerText=NewState;
}

</script>
 
B

bruce barker

your javascript replaces the div with text (outerText), so it no longer
exists. you probably wanted to set innerText

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top