title: how do I pass a variable from an input box on one page to another page, then submit it?
body: <p>Here is some code written by a helpful member of this site (the first section) and I put on my site in search2.tpl (I use Smarty templates). The second code bit is the search form on page ONE of my test site, and the third code bit, the entire template from page TWO (incorporating the code from the first section).</p>
  
  <p>What I want to do is "capture" the input from the form on page ONE (second code section), and then use this data to auto-submit to the form on page TWO (third code section). The code, as is, doesn't error out, and goes to the search page when I type in a search query and click submit, but it doesn't search for the entered text or do anything except maybe refresh itself.</p>
  
  <p>Any ideas or help would be greatly appreciated!</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  &lt;!-- 
    function checkForAutoSearch()
    {
      var searchString = &lt;?php echo (!empty($_POST['new_search_text'])) ? $_POST['new_search_text'] : ''; ?&gt;;
  
      if (searchString)
      {
        // put searchString into the second search field
        document.getElementById('search_text').value = searchString;
  
        // up in your search form, assign the form tag an id first: id="search_form_new"
        // then submit the form:
        document.getElementById('search_form_new').submit();
      }
    }
  
    // now fire this function whenever the page loads
    window.onload = checkForAutoSearch;
  //--&gt;
  &lt;/script&gt;
  
  -------------
  
  &lt;form id="searchForm_newsearch" action="./search2.php" method="post"&gt;&lt;input type="text" name="new_search_text" value=""&gt;&lt;input type="submit" value="Search"&gt;&lt;input type="submit" value="Cancel" onclick="showSearchLink();return false;"&gt;&lt;/form&gt;&lt;a id="searchLink" class="button_link_main" href="./search2.php" onclick="showSearchForm();return false;"&gt;&lt;img src="/images/search.png" onmouseover="this.src='/images/searchsite_hover.png'" onmouseout="this.src='/images/search.png'" /&gt;&lt;/a&gt;
  
  --------------
  
  {literal}
  &lt;script type="text/javascript"&gt;
  &lt;!-- 
    function checkForAutoSearch()
    {
      var searchString = &lt;?php echo (!empty($_POST['new_search_text'])) ? $_POST['new_search_text'] : ''; ?&gt;;
  
      if (searchString)
      {
        // put searchString into the second search field
        document.getElementById('search_text').value = searchString;
  
        // up in your search form, assign the form tag an id first: id="search_form_new"
        // then submit the form:
        document.getElementById('search_form_new').submit();
      }
    }
  
    // now fire this function whenever the page loads
    window.onload = checkForAutoSearch;
  //--&gt;
  &lt;/script&gt;
  {/literal}
  
  &lt;img src='./images/icons/search48.gif' border='0' class='icon_big'&gt;
  &lt;div&gt;{lang_print id=924}&lt;/div&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  
  &lt;form id="search_form_new" action='search2.php' name='search_form' method='post'&gt;
  &lt;table cellpadding='0' cellspacing='0' align='center'&gt;
  &lt;tr&gt;
  &lt;td class='search'&gt;
    &lt;table cellpadding='0' cellspacing='0' align='center'&gt;
    &lt;tr&gt;
    &lt;td&gt;{lang_print id=925}&lt;/td&gt;
    &lt;td&gt; &lt;input style='background-color:#CCCCCC' type='text' size='30' class='text' name='search_text' id='search_text' value='{$search_text}' maxlength='100'&gt;&lt;/td&gt;
    &lt;td&gt;
       &lt;input type='submit' class='button' value='{lang_print id=646}'&gt;
      &lt;input type='hidden' name='task' value='dosearch'&gt;
      &lt;input type='hidden' name='t' value='0'&gt;
    &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;td&gt; &lt;/td&gt;
    &lt;td colspan='2'&gt; &lt;b&gt;-=&lt;a href='search_advanced.php'&gt;Browse Members&lt;/a&gt;=-&lt;/b&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;br&gt;
  
  {if $search_text != ""}
  
    {if $is_results == 0}
  
      &lt;table cellpadding='0' cellspacing='0' align='center'&gt;
      &lt;tr&gt;
      &lt;td class='result'&gt;
        &lt;img src='./images/icons/bulb16.gif' class='icon'&gt;
        {lang_sprintf id=927 1=$search_text}
      &lt;/td&gt;
      &lt;/tr&gt;
      &lt;/table&gt;
  
    {else}
  
  
      {* SHOW DIFFERENT RESULT TOTALS *}
      &lt;table class='tabs' cellpadding='0' cellspacing='0'&gt;
      &lt;tr&gt;
      &lt;td class='tab0'&gt; &lt;/td&gt;
        {section name=search_loop loop=$search_objects}
          &lt;td class='tab{if $t == $search_objects[search_loop].search_type}1{else}2{/if}' NOWRAP&gt;{if $search_objects[search_loop].search_total == 0}{lang_sprintf id=$search_objects[search_loop].search_lang 1=$search_objects[search_loop].search_total}{else}&lt;a href='search2.php?task=dosearch&amp;search_text={$url_search}&amp;t={$search_objects[search_loop].search_type}'&gt;{lang_sprintf id=$search_objects[search_loop].search_lang 1=$search_objects[search_loop].search_total}&lt;/a&gt;{/if}&lt;/td&gt;
          &lt;td class='tab'&gt; &lt;/td&gt;
        {/section}
        &lt;td class='tab3'&gt; &lt;/td&gt;
      &lt;/tr&gt;
      &lt;/table&gt;
  
      &lt;div class='search_results'&gt;
  
        {* SHOW PAGES *}
        {if $p != 1}&lt;a href='search2.php?task=dosearch&amp;search_text={$url_search}&amp;t={$t}&amp;p={math equation='p-1' p=$p}'&gt;« {lang_print id=182}&lt;/a&gt;  |  {/if}
        {if $p_start == $p_end}
          &lt;b&gt;{lang_sprintf id=184 1=$p_start 2=$total_results}&lt;/b&gt; ({lang_sprintf id=928 1=$search_time}) 
        {else}
          &lt;b&gt;{lang_sprintf id=185 1=$p_start 2=$p_end 3=$total_results}&lt;/b&gt; ({lang_sprintf id=928 1=$search_time}) 
        {/if}
        {if $p != $maxpage}  |  &lt;a href='search2.php?task=dosearch&amp;search_text={$url_search}&amp;t={$t}&amp;p={math equation='p+1' p=$p}'&gt;{lang_print id=183} »&lt;/a&gt;{/if}
  
        &lt;br&gt;&lt;br&gt;
  
        {* SHOW RESULTS *}
        {section name=result_loop loop=$results}
  
      &lt;div class='search_result{cycle name="class_name" values="1,2,2,1"}' style='width: 400px; float: left; border: 1px solid #CCCCCC; margin: 5px;'&gt;
      &lt;table cellpadding='0' cellspacing='0'&gt;
          &lt;tr&gt;
          &lt;td valign='top' style='padding-right: 4px;'&gt;
        &lt;a href="{$results[result_loop].result_url}" class="title"&gt;&lt;img src='{$results[result_loop].result_icon}' class='photo' width='60' height='60' border='0'&gt;&lt;/a&gt;
      &lt;/td&gt;
      &lt;td valign='top'&gt;
            &lt;div class='search_result_text'&gt;
          {capture assign='result_title'}{lang_sprintf id=$results[result_loop].result_name 1=$results[result_loop].result_name_1}{/capture}
              &lt;a href="{$results[result_loop].result_url}" class="title"&gt;{$result_title|truncate:40:"...":true}&lt;/a&gt;
              &lt;div class='search_result_text2'&gt;{lang_sprintf id=$results[result_loop].result_desc 1=$results[result_loop].result_desc_1 2=$results[result_loop].result_desc_2 3=$results[result_loop].result_desc_3}&lt;/div&gt;
          {if $results[result_loop].result_online == 1}&lt;div style='margin-top: 5px;'&gt;&lt;img src='./images/icons/online16.gif' border='0' class='icon'&gt;{lang_print id=929}&lt;/div&gt;{/if}
            &lt;/div&gt;
      &lt;/td&gt;
      &lt;/tr&gt;
      &lt;/table&gt;
      &lt;/div&gt;
          {cycle name="clear_cycle" values=",&lt;div style='clear: both; height: 0px;'&gt;&lt;/div&gt;"}
        {/section}
  
        &lt;div style='clear:both;'&gt;&lt;/div&gt;&lt;br /&gt;
  
        {* SHOW PAGES *}
        {if $p != 1}&lt;a href='search2.php?task=dosearch&amp;search_text={$url_search}&amp;t={$t}&amp;p={math equation='p-1' p=$p}'&gt;« {lang_print id=182}&lt;/a&gt;  |  {/if}
        {if $p_start == $p_end}
          &lt;b&gt;{lang_sprintf id=184 1=$p_start 2=$total_results}&lt;/b&gt; ({lang_sprintf id=928 1=$search_time}) 
        {else}
          &lt;b&gt;{lang_sprintf id=185 1=$p_start 2=$p_end 3=$total_results}&lt;/b&gt; ({lang_sprintf id=928 1=$search_time}) 
        {/if}
        {if $p != $maxpage}  |  &lt;a href='search2.php?task=dosearch&amp;search_text={$url_search}&amp;t={$t}&amp;p={math equation='p+1' p=$p}'&gt;{lang_print id=183} »&lt;/a&gt;{/if}
  
  
      &lt;/div&gt;
    {/if}
  {/if} 
  </code></pre>