Jump to content

Parent URL from iframe


Zool

Recommended Posts

Hi,

 

In a parent/iframe page, I would like to update the parent URL on a change in the iframe.  Here is a description of my problem:

 

I have a booking page with an iframe.  The iframe has a calendar script for selecting an available date; this date is passed to the parent page to complete the booking.  I get the iframe url from the parent page with the script below which works fine: 

src="iframe.php?id_item=<?php echo $_REQUEST["id_item"] ?>" 

 

I however would like to have the parent URL update when a user changes the item_id in the iframe.  Is there a way to pass the “item_id” value to the parent to update the URL?

I have a select box in the iframe which is used to change the item_id:

<select name="id_item" class="select" onchange="this.form.submit();"> 
'.sel_list_items($_REQUEST["id_item"]).' 
</select>

 

Is there a way to add a script to the onchange command to send the item_id to the parent URL?

Link to comment
Share on other sites

I tried the code below, but it doesn't seem to work.

 

parent.document.getElementById('id_item').value = 'id_item';

 

What am I getting wrong?

 

Just to add to the record, I am learning PHP as I build my site, so have a very basic knowledge.  I appreciate any help/advise given.

 

Thanks,

Link to comment
Share on other sites

HI,

 

The parent page has the a iframe and a form.  a snippet of the code is:

 

 

  <div id="mainContent">
<div id="frameedge" align="center" >
<iframe id="frame" width="650" height="450" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="iframe.php?id_item=<?php echo $_REQUEST["id_item"] ?>">Calendar</iframe>
</div>


<div id='BookingForm_errorloc' class='error_strings' style=''></div>
<form action="formsubmit.php" method="POST" name="BookingForm" id="BookingForm" url="formsubmit.php" width="600" height="1500" >
<!-- form inputs start here -->

 

the iframe code is:

<body>
<?php
$idno = $_REQUEST["id_item"];
echo '
<form action="" method="get" name="Calendar" >
		<div class="clear"></div>
	<h2>'.itemTitle(ID_ITEM).'</h2>

  <div id="cal_wrapper" align="center">

	<div id="cal_controls" >  <!-- calendar month change buttons -->

		<div id="cal_prev" title="Previous"><img src="images/icon_prev.gif"></div> <!--  class="cal_button"-->
		<div id="cal_next" title="Next"><img src="images/icon_next.gif"></div>

		<div id="cal_admin"><!-- calendar change item select box -->

			<select name="id_item" class="select" onchange="this.form.submit();"> 
				'.sel_list_items($_REQUEST["id_item"]).' 
			</select>
		</div>	

		<!-- end options -->
	</div>

	<div id="the_months" align="center">  <!-- Draw calendar -->
		'.$calendar_months.'
	</div>
	<div id="key_wrapper">  <!-- Draw calendar key -->
		'.$calendar_states.'

	</div>
	<div class="clear"></div>
		</div>
  </form> 

';
?>

</body>

 

What I would like to do is to add a function to the onchange of the iframe to update the item_id in the parent page.

Link to comment
Share on other sites

Hi,

 

i use the id_item in the url to select the item to show the calendar for.  the iframe picks up the id_item from the parents url "/test.php?id_item=3".  there is a form in the parent page which the user books the item, so i need to know the id_item to book the correct item (even if it is passed to a variable $id).  the problem is that if the user changes the id_item in the iframe, i cannot get this value back to the parent page. 

 

Thank you for your help on this - very much appreciated!

 

[attachment deleted by admin]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.