setting value in iframe from parent window
Hi,
I have a jsp page that has a iframe which calls another jsp. it looks like:
<iframe name="iframesaveContractDetail" id="iframesaveContractDetail" src="saveMoreContractDetail.jsp" WIDTH="50%" HEIGHT="50%" frameborder="no"></iframe>
When my jsp pge containing the iframe loads it gets a value thru request.getParameter which i have to pass to my iframe on page load so that the iframe can query the database and retrieve values. I can successfully pass value to iframe on submitting of page, but how do i pass value to iframe without submitting the page ?
I have tried setting the value into an form element in iframe using
window.frames[iframesaveContractDetail].document.forms[0].elementByName[clinicalID] = "32";
but that gives me an error "iframesaveContractDetail is undefined" and when i tried to display the iframe name thru window.frames[0].name it shows the value as null.
Pleasee give me ur inputs on how to deal with this.
[997 byte] By [
ruby_sa] at [2007-11-26 13:43:44]

> When my jsp pge containing the iframe loads it gets a
> value thru request.getParameter which i have to pass
> to my iframe on page load so that the iframe can
> query the database and retrieve values. I can
> successfully pass value to iframe on submitting of
> page, but how do i pass value to iframe without
> submitting the page ?
What do you mean by "submitting the page" -- submit a form contained in the outer page with the IFRAME as target frame?
> window.frames[iframesaveContractDetail].document.forms
> [0].elementByName[clinicalID] = "32";
If iframesaveContractDetail is to be the name of the IFRAME, put it in quotes. Otherwise the browser will try to interpret it as a JS variable / object reference. Additionally, the "elementByName" part looks dubious to me, it should be named "elements" only, and "clinicalID" should be in quotes, again. Last but not least, you're missing the "value" property which you want to assign "32" to.
Note: this is actually a Java forum, not a JavaScript one.
by submitting a page i do mean submitting the form containing in outer page with iframe as target frame.
on ur suggestion, i did put quotes around iframesaveContractDetail which is the name of the iframe and around clinicalID. I changed it to elements and added .value . but still it doesnt work .. it gives me an error which is
window.frames.iframesaveConractDetail.document is null or not a object.
How can i get this resolved.