View Full Version : Passing value ... confuse ! help me :(

11-15-2006, 06:25 PM
I'm trying pass value into value properties of <param> of <object> tag by javascript.

Following is HTML code:
<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" id="WindowsMediaPlayer1">
<param name="FileName" value="" /> <!--Need pass value-->
<input type="button" name="but" id="but" value="Song" onClick="test()" /> </form>

...and js code as below:

<script type="text/javascript">
function test() {
var b = document.getElementById("WindowsMediaPlayer1").FileName.value;
b = "bendoihiuquanh.mp3"; //I want b reference to value of <param>

I don't know what i must do now? :( help me !

(My player will play a song when I choose...otherwise, it doesn't work)

11-15-2006, 06:44 PM

you might try using the DOM ( getElementById() / getElementByTagName('param') )

to access those values too.
Giving each param an id=" "

11-16-2006, 03:27 PM
I tried as you said :

function test() {
var b = document.getElementById("File").value;
b = "bendoihiuquanh.mp3";

<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" id="WindowsMediaPlayer1">
<param id="File" name="FileName" value=""/>
<input type="button" name="but" id="but" value="Click to play" onClick="test()" />

...but WMP still not run !

(Moreover, I thought function need return a value to reference to value properties of <param> and I tried but incorrect... :( )

help me !