...

View Full Version : Updating DOM Components



richard_j_green
01-19-2006, 01:16 PM
Hey all - First post :thumbsup:

I've not done much in the way of JS, if really anything other than using javascript.com before, so this may be me bieng quite m00bish, but I am having problems with my script on a page.

In a nutshell, the script I have currently allows my viewers to make a selection from a drop-down list, and as a result, the embedded WMP object below starts streaming the selected video.

WMP gets the video name from the VALUE= element of each list item.

My aim is that as well as the page starting the selected video, that a paragraph of text will appear under the WMP object based on the selection showing information regarding that video.

I've tried playing with a VAR element, and then using document.write to print the variable name to the screen, but this only writes the value of the variable at the time of page loading, and does not refresh.

My source code is actually live as a page viewable at http://www.nickypenn.plus.com/videos.html for anyone that's able to help me with this.

Thanks very much.

rlemon
01-19-2006, 07:45 PM
var text = new Array('text for selection 1','text for selection 2','text for selection 3');

var selIndex = document.formName.selName.selectedIndex;
var txtObj = document.getElementById('txtObj');
txtObj.innerHTML = text[selIndex];

<form name="formName">
<select name="selName">
<option ...>....</option>
<option ...>....</option>
<option ...>....</option>
<option ...>....</option>
<option ...>....</option>
</select>
</form>
<div id='txtObj'></div>

richard_j_green
01-19-2006, 09:18 PM
Thanks very much.

And will that code allow the DOM to update to display the paragraph of text related to the DIV Id selection?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum