Bluehost.com Web Hosting $6.95

Passing variable to a page in a frameset

This is a discussion on Passing variable to a page in a frameset within the PHP General forums, part of the PHP Programming Forums category; On 15 Aug 2008, at 19:50, Jody Cleveland wrote: > On Aug 15, 2008, at 1:46 PM, Stut ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #21 (permalink)  
Old 08-15-2008
Stut
 
Posts: n/a
Default Re: [PHP] Re: Passing variable to a page in a frameset

On 15 Aug 2008, at 19:50, Jody Cleveland wrote:
> On Aug 15, 2008, at 1:46 PM, Stut wrote:
>> On 15 Aug 2008, at 19:39, Jody Cleveland wrote:
>>> On Aug 15, 2008, at 1:22 PM, Warren Vail wrote:
>>>
>>>> Actually you may want to check back with basic html at the "target"
>>>> parameter on your search "form" statement.
>>>>
>>>> HTH,
>>>>
>>>> Warren Vail
>>>> Vail Systems Technology
>>>> warren@vailtech.net
>>>
>>> Target won't work for me because the originating page with the
>>> search box is not part of any frameset. I'm trying to get the
>>> search results from that page to go to a page that is part of a
>>> frameset.

>>
>> Are you saying that the frame you want to have the search results
>> shown in doesn't exist when the search form is submitted? If it
>> does then it doesn't matter where the form is, just specify the
>> target as the name of the frame and it will almost certainly work.
>>
>> If however you want the search to create the frameset when it runs
>> then you have a completely different problem which is best solved
>> using some sort of session. The script that handles the POST will
>> need to store the details of the search somewhere and output the
>> frameset. The frame that needs to contain the results would then
>> grab the details and run the search outputting the results.

>
> That is exactly what I want. I apologize for the confusion. I was
> having a hard time trying to put what I was trying to do in words.
> But, yes, your second paragraph is exactly what I want to do. My
> knowledge of PHP is very limited, and I've tried to search for
> something that will do this, but couldn't find anything.


Ok, then I have to ask the question... why frames?

If you really need frames then you need to come up with a way to pass
the search from the script the search form loads to the specific frame
in the frameset it outputs. You could do this through a GET parameter,
or via a session or in several other ways. In any case you'd be far
better off not using frames if possible, so why frames?

-Stut

--
http://stut.net/
Reply With Quote
  #22 (permalink)  
Old 08-15-2008
Dan Shirah
 
Posts: n/a
Default Re: [PHP] Re: Passing variable to a page in a frameset

>
> That is exactly what I want. I apologize for the confusion. I was having a
> hard time trying to put what I was trying to do in words. But, yes, your
> second paragraph is exactly what I want to do. My knowledge of PHP is very
> limited, and I've tried to search for something that will do this, but
> couldn't find anything.
>
> - jody



In that case, I would not use frames at all. I believe in the top frame all
you wanted to store was the search text, right?

Just have your search link do something like this:

<html>
<head>
<script language="JavaScript">
<!--
function submitForm() {
document.search_form.action='
http://beta.menashalibrary.org/sites...archframe.html
';
document.search_form.submit();
}
//-->
</script>
</head>
<body>
<form name="search_form" method="post" action="">
<input type="text" name="search_name" value="">
<a href="javascript:submitForm()">SEARCH</a>
</form>
</body>
</html>

And then on
http://beta.menashalibrary.org/sites...archframe.html
just
assign your posted search value and make a hidden form field.
<html>
<head>
<body>
<?php
$searched_text = $_POST['search_name'];
?>
<form name="my_search" method="post" action="">
<input type="hidden" name="search_text" value="$searched_text">
<table width='800' border='0' align='center' cellpadding='2' cellspacing='2'
bordercolor='#000000'>
<tr>
<td><?php echo "You searched for: ".$searched_text; ?></td>
</tr>
</table>
</form>
</body>
</html>

Reply With Quote
  #23 (permalink)  
Old 08-15-2008
Jody Cleveland
 
Posts: n/a
Default Re: [PHP] Re: Passing variable to a page in a frameset


On Aug 15, 2008, at 2:05 PM, Stut wrote:

> On 15 Aug 2008, at 19:50, Jody Cleveland wrote:
>> On Aug 15, 2008, at 1:46 PM, Stut wrote:
>>> On 15 Aug 2008, at 19:39, Jody Cleveland wrote:
>>>> On Aug 15, 2008, at 1:22 PM, Warren Vail wrote:
>>>>
>>>>> Actually you may want to check back with basic html at the
>>>>> "target"
>>>>> parameter on your search "form" statement.
>>>>>
>>>>> HTH,
>>>>>
>>>>> Warren Vail
>>>>> Vail Systems Technology
>>>>> warren@vailtech.net
>>>>
>>>> Target won't work for me because the originating page with the
>>>> search box is not part of any frameset. I'm trying to get the
>>>> search results from that page to go to a page that is part of a
>>>> frameset.
>>>
>>> Are you saying that the frame you want to have the search results
>>> shown in doesn't exist when the search form is submitted? If it
>>> does then it doesn't matter where the form is, just specify the
>>> target as the name of the frame and it will almost certainly work.
>>>
>>> If however you want the search to create the frameset when it runs
>>> then you have a completely different problem which is best solved
>>> using some sort of session. The script that handles the POST will
>>> need to store the details of the search somewhere and output the
>>> frameset. The frame that needs to contain the results would then
>>> grab the details and run the search outputting the results.

>>
>> That is exactly what I want. I apologize for the confusion. I was
>> having a hard time trying to put what I was trying to do in words.
>> But, yes, your second paragraph is exactly what I want to do. My
>> knowledge of PHP is very limited, and I've tried to search for
>> something that will do this, but couldn't find anything.

>
> Ok, then I have to ask the question... why frames?
>
> If you really need frames then you need to come up with a way to
> pass the search from the script the search form loads to the
> specific frame in the frameset it outputs. You could do this through
> a GET parameter, or via a session or in several other ways. In any
> case you'd be far better off not using frames if possible, so why
> frames?


I work for a consortium of 30 libraries. Each library has their own
website, but they all share the same web catalog. On each library's
website there is a search box to search the catalog, which is on a
completely different server from the websites. We've been finding that
once people use that search box, they get distracted with the catalog
and have no easy way to get back to the library's website. The problem
I was tasked with is, coming up with a way to search the catalog with
an easy way to return to where the user was before they initiated the
search.

The only way I thought to do this was to use a frameset for the search
results. Which, you can see here:
http://beta.menashalibrary.org/sites...archframe.html

If anyone has any ideas, other than using frames for the results, I'd
love to hear them. The problem is, there's nothing I can do on the web
catalog end.

- jody
Reply With Quote
  #24 (permalink)  
Old 08-15-2008
Stut
 
Posts: n/a
Default Re: [PHP] Re: Passing variable to a page in a frameset

On 15 Aug 2008, at 20:21, Jody Cleveland wrote:

> I work for a consortium of 30 libraries. Each library has their own
> website, but they all share the same web catalog. On each library's
> website there is a search box to search the catalog, which is on a
> completely different server from the websites. We've been finding
> that once people use that search box, they get distracted with the
> catalog and have no easy way to get back to the library's website.
> The problem I was tasked with is, coming up with a way to search the
> catalog with an easy way to return to where the user was before they
> initiated the search.
>
> The only way I thought to do this was to use a frameset for the
> search results. Which, you can see here:
> http://beta.menashalibrary.org/sites...archframe.html


Is POST the only way to get the search results, or will it work with a
GET?

If GET will work then you need to set the search form to post to a
script on your site which then outputs a frameset with a URL on your
server that shows the header, and the URL for the shared search server
with all the POSTed variables as GET parameters as the second frame.
Job done.

If not then you're going to need to play silly wotsits with a hidden
form in the top frame which reposts the search to the bottom form. Not
pretty and would require JS but it should work.

-Stut

--
http://stut.net/
Reply With Quote
  #25 (permalink)  
Old 08-15-2008
Jody Cleveland
 
Posts: n/a
Default Re: [PHP] Re: Passing variable to a page in a frameset


On Aug 15, 2008, at 2:27 PM, Stut wrote:

> On 15 Aug 2008, at 20:21, Jody Cleveland wrote:
>
>> I work for a consortium of 30 libraries. Each library has their own
>> website, but they all share the same web catalog. On each library's
>> website there is a search box to search the catalog, which is on a
>> completely different server from the websites. We've been finding
>> that once people use that search box, they get distracted with the
>> catalog and have no easy way to get back to the library's website.
>> The problem I was tasked with is, coming up with a way to search
>> the catalog with an easy way to return to where the user was before
>> they initiated the search.
>>
>> The only way I thought to do this was to use a frameset for the
>> search results. Which, you can see here:
>> http://beta.menashalibrary.org/sites...archframe.html

>
> Is POST the only way to get the search results, or will it work with
> a GET?
>
> If GET will work then you need to set the search form to post to a
> script on your site which then outputs a frameset with a URL on your
> server that shows the header, and the URL for the shared search
> server with all the POSTed variables as GET parameters as the second
> frame. Job done.


GET should work too. Do you know of any examples anywhere online for
this? My brain shuts off at the thought of how I'd do that.

- jody
Reply With Quote
  #26 (permalink)  
Old 08-15-2008
Stut
 
Posts: n/a
Default Re: [PHP] Re: Passing variable to a page in a frameset

On 15 Aug 2008, at 20:34, Jody Cleveland wrote:
>
> On Aug 15, 2008, at 2:27 PM, Stut wrote:
>
>> On 15 Aug 2008, at 20:21, Jody Cleveland wrote:
>>
>>> I work for a consortium of 30 libraries. Each library has their
>>> own website, but they all share the same web catalog. On each
>>> library's website there is a search box to search the catalog,
>>> which is on a completely different server from the websites. We've
>>> been finding that once people use that search box, they get
>>> distracted with the catalog and have no easy way to get back to
>>> the library's website. The problem I was tasked with is, coming up
>>> with a way to search the catalog with an easy way to return to
>>> where the user was before they initiated the search.
>>>
>>> The only way I thought to do this was to use a frameset for the
>>> search results. Which, you can see here:
>>> http://beta.menashalibrary.org/sites...archframe.html

>>
>> Is POST the only way to get the search results, or will it work
>> with a GET?
>>
>> If GET will work then you need to set the search form to post to a
>> script on your site which then outputs a frameset with a URL on
>> your server that shows the header, and the URL for the shared
>> search server with all the POSTed variables as GET parameters as
>> the second frame. Job done.

>
> GET should work too. Do you know of any examples anywhere online for
> this? My brain shuts off at the thought of how I'd do that.


Off the top of my head and very untested...

<?php
$vars = array();
foreach ($_POST as $k => $v)
{
$vars[] = urlencode($k).'='.urlencode($v);
}
$searchurl = 'http://search.server.com/search.php?'.implode('&',
$vars);
?>
<frameset>
<frame src="/header.html" />
<frame src="<?php echo $searchurl; ?>" />
</frameset>

Modify to your own frameset/url requirements but that's the basic idea.

-Stut

--
http://stut.net/
Reply With Quote
  #27 (permalink)  
Old 08-15-2008
Dan Shirah
 
Posts: n/a
Default Re: [PHP] Re: Passing variable to a page in a frameset

>
> I work for a consortium of 30 libraries. Each library has their own
> website, but they all share the same web catalog. On each library's website
> there is a search box to search the catalog, which is on a completely
> different server from the websites. We've been finding that once people use
> that search box, they get distracted with the catalog and have no easy way
> to get back to the library's website. The problem I was tasked with is,
> coming up with a way to search the catalog with an easy way to return to
> where the user was before they initiated the search.
>
> The only way I thought to do this was to use a frameset for the search
> results. Which, you can see here:
>
> http://beta.menashalibrary.org/sites...archframe.html
>
> If anyone has any ideas, other than using frames for the results, I'd love
> to hear them. The problem is, there's nothing I can do on the web catalog
> end.
>
> - jody




Easiest solution - Open the search page in a new window. Then they can just
close it to get back to the previous window...

I now understand what you're trying to say in regards to the frames.

The top frame resides completely on your server so you can place a "Go back
to homepage" link to direct people back to YOUR libraries homepage. And the
bottom frame contains the search results page that you have no control over
and cannot alter to simply place a "Home" link on it. And that should remain
since the global search results page is accessed by multiple libraries.

Like I said above, the easiest thing to do is just open it in a seperate
window so they can close it at any time and still be at the same place on
your libraries website.

Reply With Quote
  #28 (permalink)  
Old 08-15-2008
Dan Shirah
 
Posts: n/a
Default Re: [PHP] Re: Passing variable to a page in a frameset

>
> GET should work too. Do you know of any examples anywhere online for this?
>> My brain shuts off at the thought of how I'd do that.
>>
>> - jody

>
>

When you GET a value you are retrieving a passed value that appears in the
address bar:
Example

http://www.mysite.com?name=joe

www.mysite.com is the website

?name=joe is the value being passed by GET

To put this value into a PHP variable you would simply do:
<?php
$name = $_GET['name'];
?> <http://www.google.com/search?hl=en&q=encrypt+javascript>

Reply With Quote
  #29 (permalink)  
Old 08-15-2008
Dan Shirah
 
Posts: n/a
Default Re: [PHP] Re: Passing variable to a page in a frameset

On 8/15/08, Dan Shirah <mrsquash2@gmail.com> wrote:
>
> GET should work too. Do you know of any examples anywhere online for
>>> this? My brain shuts off at the thought of how I'd do that.
>>>
>>> - jody

>>
>>

> When you GET a value you are retrieving a passed value that appears in the
> address bar:
> Example
>
> http://www.mysite.com?name=joe <http://www.mysite.com/?name=joe>
>
> www.mysite.com is the website
>
> ?name=joe is the value being passed by GET
>
> To put this value into a PHP variable you would simply do:
> <?php
> $name = $_GET['name'];
> ?>
>


Although, since you have no control over the actual search page to edit the
code and have it pull in the $_GET[''] values you will probably have to
disect the search page to get its form elements so you can feed them to it
and force a submit.

I just looked at your site, and after I input my search criteria and click
submit I have to again enter in the search criteria and submit to actually
get some results.

Reply With Quote
  #30 (permalink)  
Old 08-15-2008
Dan Shirah
 
Posts: n/a
Default Re: [PHP] Re: Passing variable to a page in a frameset

There you go!

Entering in the search criteria pulls up the search in a new window and
automatically pulls results based on your search. Then I can just close the
window to return to where I was on your site.

I think that is simple and easy to use. And I'm sure not much of a headache
for you!

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 02:34 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0