473,473 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

IE - accessing select list from the iframe

Hi,

I have a selection list in my form. I also have an iframe in this
document.

I am trying to access the selection list from my iframe as given
below. It works in Firefox but not in IE.

var aaa = "navigator";
var bbb = aaa.appName;
var selopt = "";
if(bbb == "Microsoft Internet Explorer")
{
selopt = parent.document.getElementById("select1"); - - - - -
here i am able to get the object
}
else
{
selopt = parent.document.getElementsByName('select1')[0];
}

IE :
var val = selopt.options[0].value; - - - - - - -here i am not getting
the value.

Please advise.

Thanks,
Dev.

Jan 29 '07 #1
1 1462


On Jan 29, 4:59 pm, karthickd...@gmail.com wrote:
Hi,

I have a selection list in my form. I also have an iframe in this
document.

I am trying to access the selection list from my iframe as given
below. It works in Firefox but not in IE.

var aaa = "navigator";
var bbb = aaa.appName;
var selopt = "";
There is no need to initialise a variable with a value if you intend
to set it to something later,

var selopt;

is fine.

if(bbb == "Microsoft Internet Explorer")
{
selopt = parent.document.getElementById("select1"); - - - - -
here i am able to get the object}else
{
selopt = parent.document.getElementsByName('select1')[0];

}IE :
var val = selopt.options[0].value; - - - - - - -here i am not getting
the value.

Please advise.
Firstly, ditch the browser detection code, it's worthless. If either
of the methods work in IE (and both should), they'll work in the rest
(but don't forget browser detection to allow for oldies like IE 4,
Navigator 4, some mobile browsers, et al).

Secondly, if the option doesn't have its value attribute set, it is
supposed to return the value of its text attribute. IE doesn't do
this, so I'll guess that you haven't set the value attribute.

Try something like:

var sel = parent.document.getElementById("select1");
var opt = selopt.options[selopt.selectedIndex];
var val = opt.value || opt.text;

--
Rob

Jan 29 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: J. J. Cale | last post by:
I want to access the DOM. Can something like this be done with PHP or a combination of PHP/JAVASCRIPT? not tested! <html><head><title>DOM test</title> <?php $inFileName = 'test.js'; $outFileName...
8
by: Frédéric Mayot | last post by:
Hi, I have an HTML page like this : --- test.html <html> <body> <form> <iframe id="frametest" name="frametest" src="iframe.html"></iframe> <select multiple...
5
by: hiroshi ochi | last post by:
Hello, Using MSIE 6.0 and above, with javascript is it possible to display an individual tooltip for each item in a listbox? I need this functionality to show the listitems that are longer...
1
by: R | last post by:
Hello, I have a frame in which there are 2 IFrames., both being loaded from the same domain. One IFrame is loaded from http://test1.xyz.com and the other IFrame is loaded from...
3
by: Greg | last post by:
Javascript Folks, I am relatively new to javascript and am working on a script where I want to utilizes a couple of iframes and format text in them. I have run into a problem with getting the...
4
by: Paul Brant | last post by:
Hi all, I have a page with an IFRAME in it. From a script in the main ( parent ) page I instruct the IFRAME to load a specific URL. The URL contains parameters that are processed by the server....
14
by: Aaron Gray | last post by:
Hi, I want to access the properties of an IFrame but seem unable to get access to the IFrames document body. <html> <body> <iframe src="test.html" id="IFrame"></iframe> </body>
3
by: matwilko | last post by:
hi, i am trying to create a simple version of itunes...and i am using iframes to do this. I have already set up the iframes using dreamweaver and used a drop-down menu to select the genre. When...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.