Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Select List 1

Status
Not open for further replies.

Arion23

IS-IT--Management
Mar 29, 2001
132
AU
Hi all,

I'm in need of some help creating a Select list, with options that are variable, based on what radio option is selected.

There are 3 radio options: A, B and ALL - If A is selected, the Select list needs to show only A options, likewise for B, and all options if ALL is selected.

I've only been able to find one example of such code ( but am having trouble understanding how it works.

Can anyone provide any info or simplified code on how I might acheive this?
 
here is an explanation from tleish: thread216-103115 B-) regards, vic
 
Thanks Vic, just what I was after :)
 
Another question, here is my scripting:

In the Head:
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
function clearListItems(select) {
for (var i = select.options.length; i >= 0; i--)
select.options = null;
}

function populateList(select, which) {
if (which == &quot;all&quot;) {
var opt = new Option('A','A');
select.options[0] = opt;
var opt = new Option('B', 'B');
select.options[1] = opt;
}
if (which == &quot;A&quot;) {
var opt = new Option('A', 'A');
select.options[0] = opt;
}
if (which == &quot;B&quot;) {
var opt = new Option('B', 'B');
select.options[0] = opt;
}
}
//-->
</SCRIPT>

And in the body, one of my radio tags looks like:

<INPUT type=radio value=A name=group
onClick='clearListItems(document.search_form.my_list);
populateList(document.search_form.my_list, &quot;A&quot;);'
>

Now this works fine in IE 5 - 5.5 and NS 3, but not in NS 4 (at least, not in 4.7)....

Is there something blindingly obvious that I have not done, or is this just a browser 'quirk'?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top