Click to See Complete Forum and Search --> : Iframes Form Question


Laster
06-28-2007, 09:09 AM
Hi,

I have a submit form in an I frame from a central source that appears on a number of my sites. There are two bits of info that are different for each site but the other parts stay the same.

Is there a way of holding the two bits of info ina function at the top of each page and then when the form is submited these two bits of info attach to the url string?

The form submits to a url with a string of queries the two I want to hold on the page rather than the iframe form are:

<input name="hotel" type="hidden" id="hotel" value="GB059">
<input name="ref" type="hidden" id="ref" value="OSGB059">

The values are different for every site. and the url attaches them like www.billiybob.com/hotels/availability?day=3&month=4&hotel=GB059 etc...

Can the form within the iframe collect the two bits of info from the parent page and add them as if they were in the form all along?

Thanks for any help :)

Laster
06-28-2007, 12:00 PM
Must be someone able to help me :confused:

Laster
06-29-2007, 02:10 AM
thinking about this,

I need to be able to make the input name="hotel" value="VAR1" that is in the Iframe find its value 'VAR1' from the parent window of he host website. Can this be done?

Laster
06-30-2007, 02:34 AM
Anyone shed any light:confused: :eek: :(

Kor
07-01-2007, 01:11 AM
You can not handle a page in a frame/iframe using javascript unless both pages (the parent and the framed/iframed one) belong to the same domain.

Laster
07-01-2007, 01:54 AM
Thanks for the reply.

If it was in the same domain, how would I go about doing it?

Kor
07-01-2007, 02:45 AM
Not very clear for me what exactly you intend to do, but, anyway, I guess you should use a server-side application, as I guess you are dealing with a DB...

Laster
07-01-2007, 03:02 AM
I actually want to sent the user to a url with prefilled query details

hotelbooknow.com/hotel?hotel=var1&ref=var2&day=16&month=4&year=07&nadult=2

where the hotel=var1 and ref=var2 are variables taken from the main window of the site and not from the iframe form which fills the remaining data.

Kor
07-01-2007, 03:13 AM
oh, I see. Are you familiar with javascript? From an iframe the objects of the parent page are to be found, via javascript, starting with the parent root object:

Could be something like


...
var var1= parent.document.getElementById('hotel').value;
var var2= parent.document.getElementById('ref').value;
location.href='hotel?hotel='+var1+'&ref='+var2+'&day=16&month=4&year=07&nadult=2';

Laster
07-01-2007, 03:17 AM
Great,

Not the bast yet with this, still learning.

What would I need to place on the main parent page? in the script section.

Kor
07-01-2007, 03:20 AM
I need nore details:

1. You want to change the location of the iframed page? Or the parent page? Or a new page?
2. To call a javascript function you need an action (click, rollover...) and an object which will handle the event (a button, a check box...). Which will be those?

Laster
07-01-2007, 03:36 AM
if the main parent page is hotel974.com/index.htm and the iframe is hotel974.com/booking/form.htm

The iframe is a booking for which has dropdowns for nadults, day, moth etc and a submit button which sends the customer to a new url to make a booking with prefilled details. The hotel=var1 and ref=var2 parts of this iframe form are supplied from the parent page which is hotel974.com/index.htm

I guess from what you have said I need the info for hotel=var1 and ref=var2 on the index page and also as a call withint the iframe form. the data can append to the upon submitting or loading the form.