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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controlling a drop_list in _top from iframe inside a layer 2

Status
Not open for further replies.

Qrosity

Technical User
Jan 9, 2008
14
ES
Here I stumble with another problem...
Is it possible to control the contents of a drop_list from an iframe embeded on a layer? I guess it is but no idea how to... I have a drop_list called SubCat2 which is empty and I would like to populate it from a link in the iframe like:
Code:
onClick="PopulateDroplist('value1','value2');"
I've been trying some stupid ways, but nothing works...
 
Qrosity, to access the element in the iframe you have to navigate to it to locate the dropdown using the frame collection.

clflava has outlined how to access elements in an iframe in this current thread: thread216-1440799

Once that is complete, you will use javascript to create Option objects. These can then be added to your dropdown by using the options property of the dropdown.

Give this a read and it should all make sense:


-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
thanks for the bigups!
headbang.gif




*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Yeah, the tip was usefull, now I know how to access the drop list from the IFRAME, I have checked out the other link as well and I have found how to empty and populate the list, but only the empty order works, after this I can't repopulate the list:
Code:
function fillSubCat2(val1,val2){
document.forms['drop_list'].SubCat2.options.length = 0;
document.forms['drop_list'].SubCat2.options[i] = new Option('val1','val2');
}
I'm using the following link for repopulating:
Code:
<a href="#" onClick="fillSubCat2("Texas","Dallas");">
Any hints??
 
Code:
function fillSubCat2(val1,val2){
document.forms['drop_list'].SubCat2.options.length = 0;
document.forms['drop_list'].SubCat2.options[[!]i[/!]] = new Option('val1','val2');
}

How does your function know what [!]i[/!] is? Is it defined somewhere else? That's probably where your problem is. Since you just set the length equal to 0 in the previous statement, you'll probably want to replace i with 0.

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top