PDA

View Full Version : passing value in frame


learnscripts
02-28-2002, 08:12 AM
hello, i've a page that use iframe ... how do i pass the value from the iframe to the main page? here're my codes:

mainpage.asp has these 2 lines

1....<iframe name="framepage" src="value.asp"></iframe>
2....<input name="" type="text" value="i need to have a value here from value.asp">


value.asp:
....<input type="text" value="5" name="passthis">

How do i get this value (5) to display in my mainpage.asp input box (line 2)?

thanks alot!

Jon Hanlon
02-28-2002, 05:02 PM
Well, if you're going to pass something into it, it would be best to name it. We also should add a couple of named forms. Change:

1....<iframe name="framepage" src="value.asp"></iframe>
2....<input name="" type="text" value="i need to have a value here from value.asp">


To be:


1....<iframe name="framepage" src="value.asp"></iframe>
1a...<form name="passer">
2....<input name="passedValue" type="text" value="i need to have a value here from value.asp">
3....</form>


and


value.asp:
....<input type="text" value="5" name="passthis">


to be:

value.asp:
....<form name="toPass">
....<input type="text" value="5" name="passthis">
....</form>




Then, from value.asp:
parent.document.forms.passer.passedValue.value = document.forms.toPass.passthis.value;

If you want to get at it from mainpage.asp:
window.document.forms.passer.passedValue.value = window.frames.framepage.document.forms.toPass.passthis.value;

Strictly speaking you only need the <form> elements for Netscape. IE is quite happy without them.