SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
-
Aug 9, 2006, 03:48 #1
- Join Date
- May 2006
- Posts
- 29
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Problem in getting a value from iframe
Hi,
Im having problem in getting a value from an iframe.
Here is my code
<script>
function IframeFunction()
{
var frame = window.parent.frames['frameId'].document.getElementById('helpContent').value;
alert(frame);
}
</script>
<iframe name="frameId" id="frameId">
<input type="hidden" id="helpContent" value="colors" />
<input type="submit" value="submit" onclick="IframeFunction()"/>
</iframe>
-
Aug 9, 2006, 04:41 #2
- Join Date
- Jan 2005
- Location
- Too far up north
- Posts
- 1,566
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
U need to put those form elements in an own page. Then you can acces the elements like this:
Code:<script type="text/javascript"> function IframeFunction() { var oIframe = window.frames.frameId; var oIframeBody = oIframe.document.body; alert(oIframeBody.document.getElementById("myDiv")); } </script> <iframe src="page.html" id="frameId"></iframe>
Bookmarks