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!

Dynamicaly filling more than 2 select boxes

Status
Not open for further replies.

zippynz

Programmer
May 17, 2001
50
NZ
Hi,
I have searched all over the place for info on how to dynamicaly fill a select box and I have found heaps on populating one box based on the results of another, however i reuire something a little more complicated than that!

I need to dynamically populate up to 30 boxes on the fly, the data is from a database and contains staff info (an id number and name) the person using the page will select the a staff member from the first box and the choose what their start/finish times (i can do this bit:) are, when they move to the next select box the staff member the selected in the last one will no longer be avalilable. is this possible? im sure it is, im just slow at learning javascript!

any help would be greatly appreciated
thanks :)
 
so, ur question is how 2 make selectbox uneditable?
if it is, check this: faq216-795 regards, vic
 
no,
what i need to do is remove options from other select boxes based on the selection made on one select box,

ill try to explain this again,

say i have 6 staff working for me, (joe, sam, bob, tim, pete, dick)
now joe, sam and pete worked today (its shift work)

Now I have made a form with 3 select boxes, In each of these select boxes I want to choose which staff member worked, so the first box I want to have a list of all the staff who work for me and I want to select joe,
so I select joe and now that he is working I dont wont to be able to select him again in another box so he will dissapear from all the other select boxes.
now we move on to selectbox 2 it has only got sam, bob, tim, pete and dick available because joe is allready working. I will select sam from this box and he will disapear from all the select boxes

hows that?
once
 
wooo.. impressed..
u're shure have seen this, but just in case:
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
// You create a new OPTION with
var opt = new Option('text', 'value');

// and insert it with
var sel = document.formName.selectName;
sel.options[sel.options.length] = opt;

// at the end of the SELECT list.
// To insert into the middle move other options up e.g.
function insertOptionAt (select, option, index) {
for (var i = select.options.length; i > index; i--)
select.options = select.options[i - 1];
select.options[index] = option;
}

// example call
insertOptionAt (document.formName.selectName, new Option('text', 'value'), 3);

// You delete an OPTION simply be setting
var sel = document.formName.selectName;
sel.options[optionIndex] = null;

//-->
</SCRIPT>
regards, vic
 
hmm,
if anything im probably a little more confused,
could you explain a little how I should use this script?
 
well, u wanted 2 remove some option from some select?
that was a solution..
i mean
var sel = document.formName.selectName;
sel.options[optionIndex] = null;
i mean u culd check thru all ur select boxes if it contains needed option & then delete it..
am i goin the wrong way?? :-I

regards, vic
 
oh ok,
i think i see what you are getting at now,
i gonna get some sleep then tackle it in the morning,
thanks for your help
ill let you know how it goes :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top