• 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

dynamically select option in drop down list  RSS feed

 
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)
 
Enjoy the full beauty of the english language. Embedded in this tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!