how to post value to multiple pages via a href in php?
I have 3 pages. index.php
, iframe-a.php
, iframe-b.php
. the relation as below.
index.php
<a href="iframe-a.php?search=something" target="frame_a">something</a>
//a group of a link, so I do not consider `from`
<iframe src="iframe-a.php" width="600px" height="600px" name="frame_a" />
iframe-a.php
$_GET['search'];//do some job
<iframe src="iframe-b.php" width="600px" height="300px" name="frame_b" />
iframe-b.php
$_GET['search'];//do some job
I search many topics, some question only about in a form
type. I wonder to know how to post value to multiple pages via a href
in php? I want pass the val开发者_如何学Goue not only in iframe-a.php
, but also in iframe-b.php
If all 3 pages are in effect refreshing, only index.php needs to know what is going on. Index.php tells the iframe pages that the url to load in the scr is.
<?php
echo '<iframe src=iframe-a.php?search=' . $string_passed_to_index.php . '>';
[That way you only have to sanitize it once.] No, bad Cups! I take that bit back.
You need to use JavaScript for this. Attach some code to the onClick event of the link and refresh both iframes manually.
Edit: Something like this (using jQuery)
$('a#your-link-id').click(function(event) {
event.preventDefault();
$('#iframe-a').attr('src', 'iframe-a.php?search=something');
$('#iframe-b').attr('src', 'iframe-b.php?search=something');
});
Note: Set the proper id
attributes in your HTML.
This is a client problem. PHP don't know anything about iframes or targets. It only processes HTTP requests.
精彩评论