• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1596
  • Last Modified:

Get value in Iframe.

I have a page with 3 frames, frame 1 possesss a iframe and inside of the iframe it has one combobox, as I make for frame 3 to get the value of combo using Javascipt
0
gpsbr
Asked:
gpsbr
  • 3
1 Solution
 
Pravin AsarPrincipal Systems EngineerCommented:
To access the selectMonth (of type <select>) in the form "MyForm" from a document loaded in the iframe named 'ifr3'
styntax is

top.ifr3.window.document.MyForm.selectMonth.options.length;

0
 
Pravin AsarPrincipal Systems EngineerCommented:
To get the value,

top.ifr3.window.document.MyForm.selectMonth.value


0
 
Pravin AsarPrincipal Systems EngineerCommented:
<html>
<head>
<title>Frame3 Access </title>
<script language="javascript">
function LoadMessage() {
        var selObj = top.ifr3.window.document.MyForm.selectMonth);
        alert ('Sel Obj : ' + selObj.options.length);
}
</script>
</head>

<body onLoad="LoadMessage();">
<iframe id="ifr1" width="100" height="100" title="iframe 1">
</iframe>
<iframe id="ifr2" height="100" width="100" title="Iframe 2">
</iframe>
<iframe id="ifr3" name="ifr3" height="100" width="100" title="iframe 3" src="form.htm">
</iframe>
</body>
</html>

<!--- form.htm -->
<html>
<head>
<title>Form in the frame ifr3 </title>
</head>
<body>
<form name="MyForm">
<select  name="selectMonth" >
  <option selected value="Jan">Jan</option>
  <option value="Feb">Feb</option>
  <option value="Mar" selected >Mar</option>
  <option value="Apr">Apr</option>
  <option value="May">May</option>
  <option value="Jun">Jun</option>
  <option value="Jul">Jul</option>
  <option value="Aug">Aug</option>
  <option value="Sep">Sep</option>
  <option value="Oct">Oct</option>
  <option value="Nov">Nov</option>
  <option value="Dec">Dec</option>
</select>
</form>
</body>
</html>

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now