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"]; ?>" >
    
    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP