Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

dynamically select option in drop down list

 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello -
I have a page with multiple frames. When a button is clicked in the lower frame, it needs to change the selected option in the drop down list in another frame based on the value of the button. I am able to access the currently selected option in the drop down list by:
function diff(p)
{
for(var i=0; i<top.frames[0].names.options.length; i++) {
alert(top.frames[0].names.options[i].value + ":" + p);
if (top.frames[0].names.options[i].value==p)
{
// this works
alert("match");
break;
}
else
{
// this works
alert("no match");
}
}
// line below does NOT work
top.frames[0].names.option[i].select;
}
Does anyone know how I can select the option that matches the value on the button? Thanks, I really appreciate your help!
 
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by verduka fox:
// line below does NOT work
top.frames[0].names.option[i].select;


I'm not a 100%, but I think it should be .selected ...

------------------
I'm a soldier in the NetScape Wars...
Joel
 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try .selected = true;
------------------
Chris Stehno (Sun Certified Programmer for the Java 2 Platform)
 
This guy is skipping without a rope. At least, that's what this tiny ad said:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic