Hello javascript users,
I'm relativly new in using javascript and tried to populate a select box based on a value chosen in a earlier selectbox.
The code i wrote doesn't seem to work and i cant figure out what is going wrong. Can someone give me some assistance.
this is the code i wrote:
<html>
<head>
<script type='text/javascript'>
var secondOptions =
{
1 :[[Beckman Coulter Electrachrom AT,101],[BioMerieux Chromostrate ATIII,127],[BioMerieux MDA ATIII,128],[Biopep Chromopep AT,109],[Biophen Antithrombin,155],[Trinity / Biopool Spectrolyse ATIII (anti-IIa),102],[Dade Behring Antithrombin Reagent,110],[Dade Behring Berichrom Antithrombin,100],[Electrochem ATIII,113],[Helena Chromz-AT,114],[Hemolab ATIII chrome (Biomerieux),115],[Immuno ATIII chrome,125],[Nobis Nobichrom Antithrombin,126],[Pacific Hemostasis Chrom AT assay,145],[Precision Biologic Chromocheck AT,150],[Renam Reachrom ATIII,160],[Stago/Roche Antithrombin III,131],[Stago/Roche Stachrom ATIII,130],[The Binding Site AT activity,135],[Trinity / Sigma Accucolor Antithrombin,129],[Unicorn ATIII,140],[Homemade, please specify ...,190],[Other, please specify ...,199]],
2 :[[Trinity / Biopool Spectrolyse ATIII (anti-Xa),103],[Chromogenix Coamatic Antithrombin,105],[Chromogenix Coamatic AT-400,106],[Chromogenix Coamatic LR Antithrombin,108],[DG-Chromat ATIII,112],[Electrochem ATIII,113],[Hyphen-Biomed Chromopep AT,117],[I.L. HemosIL Antithrombin,120],[I.L. HemosIL liquid Antithrombin,121],[Trinity / Biopool Spectrolyse ATIII (anti-Xa),103],[Homemade, please specify ...,190],[Other, please specify ...,199]],
};
function UpdateSecondary( sel ){
var secondsel = document.getElementById('secse1');
var selvalue = sel.options[sel.selectedIndex].value;
var count = secondOptions[ selvalue ].length;
secondsel.options.length = 0;
for( i =0; i<count; i++)
secondsel.options = new Option( secondOptions[selvalue][0],secondOptions[selvalue][1] );
}
</script>
<table align='left'>
<tr valign='baseline'>
<td width='200' align='left' valign='top'>Type of Assay:</td>
<td>
<select name='assa_a' width='600' STYLE='width:150px' onChange='UpdateSecondary(this);'>
<option value=0 CLASS='text'>Select from list</option>
<option value=1 CLASS='text'>Chromogenix, anti IIa</option>
<option value=2 CLASS='text'>Chromogenix, anti Xa</option>
<option value=99 CLASS='text'>Other</option>
</select>
</td>
</tr>
<tr valign='baseline'>
<td nowrap align='left'>Specify method:</td>
<td>
<select id='secse1' name='meth_a'>
<option>Please select an Assay</option>
</select>
</td>
<td><width='200' align='left' valign='top'>if other please specify</td>
<td><width='200' align='left' valign='top'><input type='text' width=200 name='nmeth_a' size='15'></td>
<tr>
athanks in advance for your help,
r mendes
I'm relativly new in using javascript and tried to populate a select box based on a value chosen in a earlier selectbox.
The code i wrote doesn't seem to work and i cant figure out what is going wrong. Can someone give me some assistance.
this is the code i wrote:
<html>
<head>
<script type='text/javascript'>
var secondOptions =
{
1 :[[Beckman Coulter Electrachrom AT,101],[BioMerieux Chromostrate ATIII,127],[BioMerieux MDA ATIII,128],[Biopep Chromopep AT,109],[Biophen Antithrombin,155],[Trinity / Biopool Spectrolyse ATIII (anti-IIa),102],[Dade Behring Antithrombin Reagent,110],[Dade Behring Berichrom Antithrombin,100],[Electrochem ATIII,113],[Helena Chromz-AT,114],[Hemolab ATIII chrome (Biomerieux),115],[Immuno ATIII chrome,125],[Nobis Nobichrom Antithrombin,126],[Pacific Hemostasis Chrom AT assay,145],[Precision Biologic Chromocheck AT,150],[Renam Reachrom ATIII,160],[Stago/Roche Antithrombin III,131],[Stago/Roche Stachrom ATIII,130],[The Binding Site AT activity,135],[Trinity / Sigma Accucolor Antithrombin,129],[Unicorn ATIII,140],[Homemade, please specify ...,190],[Other, please specify ...,199]],
2 :[[Trinity / Biopool Spectrolyse ATIII (anti-Xa),103],[Chromogenix Coamatic Antithrombin,105],[Chromogenix Coamatic AT-400,106],[Chromogenix Coamatic LR Antithrombin,108],[DG-Chromat ATIII,112],[Electrochem ATIII,113],[Hyphen-Biomed Chromopep AT,117],[I.L. HemosIL Antithrombin,120],[I.L. HemosIL liquid Antithrombin,121],[Trinity / Biopool Spectrolyse ATIII (anti-Xa),103],[Homemade, please specify ...,190],[Other, please specify ...,199]],
};
function UpdateSecondary( sel ){
var secondsel = document.getElementById('secse1');
var selvalue = sel.options[sel.selectedIndex].value;
var count = secondOptions[ selvalue ].length;
secondsel.options.length = 0;
for( i =0; i<count; i++)
secondsel.options = new Option( secondOptions[selvalue][0],secondOptions[selvalue][1] );
}
</script>
<table align='left'>
<tr valign='baseline'>
<td width='200' align='left' valign='top'>Type of Assay:</td>
<td>
<select name='assa_a' width='600' STYLE='width:150px' onChange='UpdateSecondary(this);'>
<option value=0 CLASS='text'>Select from list</option>
<option value=1 CLASS='text'>Chromogenix, anti IIa</option>
<option value=2 CLASS='text'>Chromogenix, anti Xa</option>
<option value=99 CLASS='text'>Other</option>
</select>
</td>
</tr>
<tr valign='baseline'>
<td nowrap align='left'>Specify method:</td>
<td>
<select id='secse1' name='meth_a'>
<option>Please select an Assay</option>
</select>
</td>
<td><width='200' align='left' valign='top'>if other please specify</td>
<td><width='200' align='left' valign='top'><input type='text' width=200 name='nmeth_a' size='15'></td>
<tr>
athanks in advance for your help,
r mendes