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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help passing form data to iframe URL

Status
Not open for further replies.

emergencyofstate

IS-IT--Management
Feb 24, 2009
3
US
Hi everyone.

I have a form that will always live in a sidebar. It has 2 fields: 'zip code' and 'keyword'. I need the results of that form to...

#1. Trigger a page on my site that contains an iframe

#2. Append the form results to an external URL to load in that iframe. (example:
Anyone have advice on the best way to accomplish this?

Thanks in advance.
 
do you have anything written so far?

TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Well the latest thing I have is:

<FORM METHOD="LINK" ACTION="pagethatholdsiframe.html">
Zip Code: <INPUT TYPE="text" NAME="ZipCode">
Keyword: <INPUT TYPE="text" NAME="KeyWord">
<INPUT TYPE="submit" VALUE="Submit">
</FORM>

I'm just unclear on the javascript to pass these two values to that page that holds the iframe then append the form data to the iframe src on to
 
how are you passing it to the external site? By querystring?

if your iframe has an ID (i.e. id="myFrame") then you can simply set the source by using

document.getElementById("myFrame").src = "
can you maybe provide the code you've written so far on pagethatholdesiframe.html?





TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Of course..and thanks so much for your help.

This is the only code I have so far for my iframe page.

<iframe src="#" id="lesson_results" name="lesson_results" scrolling="auto" frameborder="0" width="700" height="1250" marginheight="0" marginwidth="0"></iframe>

So on the form do I need to attach a function to the submission of the form?

document.getElementById("lesson_results").src = "
 
when your form is submitted, the iframegoesherepage.html page will have the values appended to the end of it - something like:

iframegoesherepage.html?zip=12345&keyword=searching

In that page, in the body tag, use the onload function to execute your javascript function that retrieves the values of ZIP & Keyword and builds a string equal to the url that you want in your iframe.

Now set the src using the document.getElementById method I mentioned above.

Here is a link on how to get the values of the querystring using javascript:



Give it a shot and if you are still having problem, post your code and I'll help out more -


TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top