![]() |
Can I select a dropdown value in an iframe? I have a page/form which I need to iframe into my website for branding purposes. The page/form I want inside the iframe has a dropdown menu which I have no control over.. but need to have that dropdown pre-select a particular menu item when it loads inside my iframe.. How do I do this? |
Re: Can I select a dropdown value in an iframe? here what you do: Warning: this works only on server side, otherwise you will see security errors and warnings. file1 <html> <body> <!-- your iframe, see file2 below --> <iframe src="frame.html" frameborder="0" width="500" height="300" id="iiframe"></iframe> <!-- get latest jquery library from google apis --> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <!-- jquery code below find in iframe with ID:iiframe, the element with ID:selcolor and option attribute value="green" and marks it as selected --> <script type="text/javascript"> (function(){ $('#iiframe').contents().find('#selcolor option[value="green"]').attr('selected', 'selected'); })(); </script> </body> </html> file2 <html> <body> <select name="selcolor" id="selcolor"> <option value="red">Red</option> <option value="green">Green</option> <option value="blue">Blue</option> </select> </body> </html> |
Re: Can I select a dropdown value in an iframe? Thanks vie.. i'll have a play with it tomorrow. |
Re: Can I select a dropdown value in an iframe? Quote:
I can drop a link to a working example if necessary. |
Re: Can I select a dropdown value in an iframe? Quote:
Code: <select id="dropdown_options">Code: <select id="dropdown_options">Note: just to be clear, you can access the iframe source in JavaScript like so: Code: <iframe name="test" id="test"></iframe> |
Re: Can I select a dropdown value in an iframe? This is great, thanks! |
| All times are GMT -6. The time now is 11:45 AM. |