PDA

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



h2q1
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-->
</object>
<form>
<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>
}
</script>

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)

Acey99
11-15-2006, 06:44 PM
ok.

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

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

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


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

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

...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 !