Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing data from a Form to an IFRAME

Status
Not open for further replies.

Exode

Programmer
Feb 17, 2004
14
CA
Hi all,

I'd like if anyone can help me to figure out how to pass data from a field of a form to an IFRAME. Right now I have a page with a list of user and when I click on the submit button, I'd like to load the IFRAME (which execute a SQL query via a PHP function to return some informations on the selected user) and put the informations back in the designated fields of my form.

So basicaly I'm trying to take a value from my form ans send it to the frame, execute the query and return the info gathered to the form to print it.

My IFRAME is already created as follow:
<iframe src="TraitementInfo.php"
name="frmUsrInfo"
width="100%" height="250"
scrolling="no"
align="left">
</iframe>

And my form containing the listitem that I want to pass to the frame and the Submit button:
<form name="formUsrMod" method="GET" action="" target="frmUsrInfo">
<input name="usrCode" maxlength="10" style="width:150;height:23" size="30"/>
<input type="button" value="Add" onClick="process();"> <input type="Button" value="Remove" onclick="removeItem()"/>
<select name="usrLstCode" size=4 onchange="moveOver();"></select>
<input type="submit" value="Show information" onClick="document.frames["frmUsrInfo"].location.href='TraitementInfo.php?usrCode='+document.formUsrMod.usrCode.value;">
</form></td>

Thanks all. Frank
 
here's a working example:

iframe.html
Code:
<body>
<form name=parentForm>
Input a value in the textbox and then click the button to send it to the Iframe<br>
<input type=text name=parentText><br>
<input type=button value='Send' onclick='javascript:blahFrame.frameForm.frameText.value=parentForm.parentText.value;'><br><br>
<iframe name=blahFrame src=iframe2.html width=100% height=50%></iframe>
</form>
</body>

iframe2.html
Code:
<body>
<form name=frameForm>
<input type=text name=frameText>
</form>
</body>

-kaht

banghead.gif
 
Are you sure it works ? It gives me an error when I press the send button

Frank
 
Worked fine for me using IE 6.0/win2000.

You are saving both pieces of code to different .html files, correct?

What error did it give you when the send button is pressed?

-kaht

banghead.gif
 
Thanks kaht, my bad now it works.

The only thing is that I need the textbox value to execute a PHP script and return some value in my iframe, and with your solution the value is passed directly to the field.

Any ways I could send the value and refresh my iframe so it execute my PHP function ?

Thanks, Frank
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top