dtufl26404 2017-03-09 13:48
浏览 127

一个textarea的内容复制到不同页面的另一个textarea

I have two pages index.php and search.php, both have a search box. If the user enters the name to be searched in the index.php Textarea and clicks on submit button the content of the Textarea should be loaded in the search.php page.

index.php

 <form action="search.php" method="post">
     <div>
          <input type="text" name="query_data" placeholder="Who would you like to find today?">
     </div>
     <div>
          <input type="submit" name="submit" value="SEARCH"></input>
     </div>
</form>

search.php

<div>
    <div>
        <input type="text" name="search" id="search" placeholder= <?php echo $_POST["query_data"]; ?> >
    </div>
    <div>
        <input type="submit" name="submit" value="SEARCH" onclick="func()"</input>
    </div>
</div>

I want the name searched in the index.php page to be the placeholder in the search.php page. The user would have to click on the search button of the search.php page to load the function func() and get the answers. This code is wrong and is not working. It is giving an error that the query is undefined. Please Help! Thanks a lot!

I have added the Javascript file also. It has Ajax and is getting the right result when used on the search.php page. The problem is not with the Javascript though!

<script type="text/javascript">
function func()
{
  var tosearch=document.getElementById("search").value;
  if(tosearch==="")
    print("<center><b>Nothing To Search For!!</b></center>");
  else
    {$.ajax({
      type: 'post',
      url: 'page2.php',
      data: {'tosearch' : tosearch},
      dataType: "html",
      success: function (result) {
            print(result);
          }
        });
    }
}
function print(result){
  document.getElementById("output").innerHTML=result;
}

  • 写回答

2条回答 默认 最新

  • dongpo0409 2017-03-09 13:57
    关注

    You are maybe missing the qoute try this:

    <input type="text" name="search" id="search" placeholder="<?php echo $_POST["query"]; ?>" >
    
    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配