View Full Version : Show text after selecting something from a listbox

01-27-2005, 11:02 AM
Can someone show me how I would make this happen

I have a listbox and depending on what what you selected differnt text will pop up underneath the listbox with out the page realoading.

It seems simple I know but i dont know where to start


01-27-2005, 12:24 PM
<select name="s" onchange="document.getElementById('desc').innerHTML=this.options[this.selectedIndex].value">
<option value="">Select one</option>
<option value="blah blah blah">item 1</option>
<option value="foo foo foo">item 2</option>
<option value="he he he">item 3</option>
<div id="desc"></div>

01-27-2005, 02:08 PM
thats exactly what I want although how would I be able to format it like add new lines and add html like tables.

01-28-2005, 02:55 AM
<script type="text/javascript">
var arr = new Array();
arr[0] = '';
arr[1] = 'This is a <a href="http://www.google.com/">link</a>.';
arr[2] = 'This is in line 1.<br />This is in line 2.';
arr[3] = '<span class="redmsg">This text uses a red Verdana font.</span>';
//...and so on
<style type="text/css">
.redmsg {font:normal 12px Verdana; color:red;}
<select name="s" onchange="document.getElementById('desc').innerHTML=arr[this.selectedIndex]">
<option value="">Select one</option>
<option value="item 1">item 1</option>
<option value="item 2">item 2</option>
<option value="item 3">item 3</option>
<div id="desc"></div>