Click to See Complete Forum and Search --> : option boxes


tbobker
12-19-2006, 07:11 AM
I want to display different text on part of a page depending on what option box is selected in the form? How can i do this?

i have a function that i wrote in the head but doesnt work


function myselect() {

var x=document.getElementById("mySelect");

for (i=0;i<x.length;i++) {

if(x.options[i].text == trial) {

document.write("trial info");
}
}


}


i put this in the select tag


<select name="attn" size="1" id="myselect">

bogu
12-19-2006, 10:46 AM
Something like this:
<div id="mesaj">The message will appear here!</div>
<select name="sel" onchange="return Change(this);">
<option value="Message 1">Message 1</option>
<option value="Message 2">Message 2</option>
<option value="Message 3">Message 3</option>
<option value="Message 4">Message 4</option>
<option value="Message 5">Message 5</option>
</select>
<script>
elem = document.getElementById('mesaj');
function Change(cmb) {
elem.innerHTML = cmb.options[cmb.selectedIndex].value;
}
</script>