Lost reference to control/div

  • Thread starter Thread starter Lloyd Sheen
  • Start date Start date
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>
 
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>
 
your javascript replaces the div with text (outerText), so it no longer
exists. you probably wanted to set innerText

-- bruce (sqlwork.com)
 
Back
Top