By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,382 Members | 1,637 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,382 IT Pros & Developers. It's quick & easy.

Dynamic HTML-Menu

P: n/a
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[i] = 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
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Janwillem Borleffs" <jw*@jwbfoto.demon.nl> schreef in bericht
news:3f***********************@news.euronet.nl...

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[i] = 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[i] = NewEntry;
}
}
JW

Jul 20 '05 #2

P: n/a
Great one! Thanks!
Cheers,
Konrad

"Janwillem Borleffs" <jw*@jwbfoto.demon.nl> schrieb im Newsbeitrag
news:3f***********************@news.euronet.nl...

"Janwillem Borleffs" <jw*@jwbfoto.demon.nl> schreef in bericht
news:3f***********************@news.euronet.nl...

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[i] = 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[i] = NewEntry;
}
}
JW

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.