Possible Duplicate:
How do you post to an iframe?
I have a form that I'd like to have do two things - submit a standard form request with one button (which works), and have a second button (that also works, partially) that opens an iframe inside the page with the value from the form appended to the iframe URL.
Here's the script I'm using:
<script language="JavaScript" type="text/javascript">
function makeFrame() {
ifrm = document.createElement("IFRAME");
ifrm.setAttribute("src", "https://www.hostname.com/filepath");
ifrm.style.width = 340+"px";
ifrm.style.height = 630+"px";
document.body.appendChild(ifrm);
}
</script>
and the form:
<FORM action="https://www.hostname.com/filepath" method="POST" name="form" id="viewGift">
<P><br>
<LABEL for="giftId">giftId: </LABEL><INPUT type="text" name="giftId"><BR>
<INPUT type="radio" name="opt1" value="1" checked> opt1<BR>
<INPUT type="radio" name="opt2" value="2"> opt2<BR>
<INPUT type="radio" name="opt3" value="3"> opt3<BR>
<INPUT type="radio" name="opt4" value="4"> opt4<BR>
<INPUT type="button" value="Send Gift" onclick="formSubmit()">
<INPUT type="button" value="Show Gift" onclick="makeFrame()">
</P>
</FORM>
My form submits correctly, but I can't figure out how to get it to pass the form giftId value to the iframe URL with the Show Gift button. If I hardcode the URL, the Show Gift button works just fine, but that doesn't help much for the page's purpose.
Basically, I need the Show Gift button to create an iframe with the URL of https://www.hostname.com/filepath/giftId , where giftId is entered by the user.