Dynamic HTML-Menu

K

Konrad Mathieu

Dynamically changing an HTML-menu:

function changeSelectMenu(v){
for(i=0;i<v;i++){
NewEntry = new Option(i+1,i,false,false);
document.Testform.Testmenu.options = NewEntry;
}
}

....works fine but:
When "v" is changed to a lower value, the old higher entries are still
visible.

How can one clear the options object before rewriting it?

Thanx and cheers,
Konrad
 
J

Janwillem Borleffs

Janwillem Borleffs said:
function changeSelectMenu(v){
document.Testform.Testmenu.length=0;
for(i=0;i<v;i++){
NewEntry = new Option(i+1,i,false,false);
document.Testform.Testmenu.options = NewEntry;
}


Sorry, missed out on the closing brace to end the for-loop:

function changeSelectMenu(v){
document.Testform.Testmenu.length=0;
for(i=0;i<v;i++){
NewEntry = new Option(i+1,i,false,false);
document.Testform.Testmenu.options = NewEntry;
}
}


JW
 
K

Konrad Mathieu

Great one! Thanks!
Cheers,
Konrad



Janwillem Borleffs said:
Janwillem Borleffs said:
function changeSelectMenu(v){
document.Testform.Testmenu.length=0;
for(i=0;i<v;i++){
NewEntry = new Option(i+1,i,false,false);
document.Testform.Testmenu.options = NewEntry;
}


Sorry, missed out on the closing brace to end the for-loop:

function changeSelectMenu(v){
document.Testform.Testmenu.length=0;
for(i=0;i<v;i++){
NewEntry = new Option(i+1,i,false,false);
document.Testform.Testmenu.options = NewEntry;
}
}


JW
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top