Forum Moderators: open
<html>
<head><script type="text/javascript">
var textBlocks = new Array(
'Select an option',
'G1 Choice1 description',
'G1 Choice2 description',
'G2 Choice1 description',
'G2 Choice2 description');
function changeText(elemid) {
var ind = document.getElementById(elemid).selectedIndex;
document.getElementById("display").innerHTML=textBlocks[ind];
}
</script></head>
<body>
<form>
<table>
<tr>
<td>Person 1</td>
<td>Information</td>
<td><select id="choice" onchange="changeText('choice')">
<option>Select</option>
<optgroup label="Category 1">
<option>G1 Choice1</option>
<option>G1 Choice2</option>
</optgroup>
<optgroup label="Category 2">
<option>G2 Choice1</option>
<option>G2 Choice2</option>
</optgroup>
</select></td>
<td><div id="display">Select an option</div></td></tr>
<tr>
<td>Person 2</td>
<td>Information</td>
<td><select id="choice" onchange="changeText('choice')">
<option>Select</option>
<optgroup label="Category 1">
<option>G1 Choice1</option>
<option>G1 Choice2</option>
</optgroup>
<optgroup label="Category 2">
<option>G2 Choice1</option>
<option>G2 Choice2</option>
</optgroup>
</select></td>
<td><div id="display">Select an option</div></td></tr>
</table></form></body>
</html>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form>
<table>
<tr>
<td>Person 1</td>
<td>Information</td>
<td>
<select id="choice1" onchange="changeText('choice1', 'display1')">
<option>Select</option>
<optgroup label="Category 1">
<option>G1 Choice1</option>
<option>G1 Choice2</option>
</optgroup>
<optgroup label="Category 2">
<option>G2 Choice1</option>
<option>G2 Choice2</option>
</optgroup>
</select>
</td>
<td>
<div id="display1">Select an option</div>
</td>
</tr>
<tr>
<td>Person 2</td>
<td>Information</td>
<td>
<select id="choice2" onchange="changeText('choice2', 'display2')">
<option>Select</option>
<optgroup label="Category 1">
<option>G1 Choice1</option>
<option>G1 Choice2</option>
</optgroup>
<optgroup label="Category 2">
<option>G2 Choice1</option>
<option>G2 Choice2</option>
</optgroup>
</select>
</td>
<td>
<div id="display2">Select an option</div>
</td>
</tr>
</table>
</form>
<script>
var textBlocks = [
'Select an option',
'G1 Choice1 description',
'G1 Choice2 description',
'G2 Choice1 description',
'G2 Choice2 description'
];
function changeText(elemid, displayId) {
var ind = document.getElementById(elemid).selectedIndex;
document.getElementById(displayId).innerHTML = textBlocks[ind];
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form id='info'>
<fieldset><legend>Person 1 Information</legend>
<select id="choice1">
<option>Select</option>
<optgroup label="Category 1">
<option>G1 Choice1</option>
<option>G1 Choice2</option>
</optgroup>
<optgroup label="Category 2">
<option>G2 Choice1</option>
<option>G2 Choice2</option>
</optgroup>
</select><span id="display1"> Select an option</span>
</fieldset>
<fieldset><legend>Person 2 Information</legend>
<select id="choice2">
<option>Select</option>
<optgroup label="Category 1">
<option>G1 Choice1</option>
<option>G1 Choice2</option>
</optgroup>
<optgroup label="Category 2">
<option>G2 Choice1</option>
<option>G2 Choice2</option>
</optgroup>
</select><span id="display2"> Select an option</span>
</fieldset>
<fieldset>
<input type='reset' value='reset' id='reset' />
</fieldset>
</form>
<script type='text/javascript' src='scripts/external.js'></script>
</body>
</html>
function select_options(){
var textBlocks = [
'Select an option',
'G1 Choice1 description',
'G1 Choice2 description',
'G2 Choice1 description',
'G2 Choice2 description'
];
document.getElementById('choice1').onchange=function(){
var ind = document.getElementById('choice1').selectedIndex;
document.getElementById('display1').innerHTML = ' '+textBlocks[ind];
}
document.getElementById('choice2').onchange=function(){
var ind = document.getElementById('choice2').selectedIndex;
document.getElementById('display2').innerHTML = ' '+textBlocks[ind];
}
}
function func_reset() {
document.getElementById('reset').onclick=function(){
document.getElementById('display1').innerHTML=" Select an option";
document.getElementById('display2').innerHTML=" Select an option";
}
}
window.onload=function(){
select_options();
func_reset();
}
I removed the table element to conform to accepted standards...
Hmmm, now if I can just learn how to indent code!