Re: Passing variable to a page in a frameset

From: Date: Fri, 15 Aug 2008 17:22:01 +0000
Subject: Re: Passing variable to a page in a frameset
References: 1 2 3 4 5 6 7  Groups: php.general 
Request: Send a blank email to php-general+get-278164@lists.php.net to get a copy of this message
On Aug 15, 2008, at 11:32 AM, Dan Shirah wrote:
In the <head> of my page, I have this: <script type="text/javascript"> function submitForm(var1,var2) { top.mainFrame.document.my_search.text1.value = var1; top.mainFrame.document.my_search.text2.value = var2; top.mainFrame.document.my_search.submit(); document.search_form.submit(); } </script> If I type in a word in the search box http://beta.menashalibrary.org/about and hit enter, it searches the catalog just fine, but then just replaces the current page with the search results. If I click on the SEARCH link with the javascript, it does nothing. It looks like you haven't adapted the example I gave you to conform to your page/form structure. top.mainFrame.document.my_search.text1.value = var1; The frame you are populating may not be named mainFrame The form in your destination frame may not be named my_search The input in you destination frame may not be text1 You have to modify these areas to suit your application and add or remove more as needed.
So, I had this all wrong before. Basically, I need two forms, right? One on my originating page, and one on the page within the frameset I want to pass the values to. Correct? My form, which I named my_search has one input field, which I named query. In the javascript, I put in this: <script type="text/javascript"> function submitForm(var1,var2) { top.mainFrame.document.my_search.query.value = var1; top.mainFrame.document.my_search.submit(); document.search_form.submit(); } </script> In the framset named mainFrame, I have a page which matches the form on the originating page. Am I on the right track? When I click on the search link, nothing happens. - jody

« previous php.general (#278164) next »