doufu2396 2013-09-19 11:25
浏览 18
已采纳

使表单从其启动的页面中检索数据......可能吗? [关闭]

im using pho forms in dreamweaver, i did a comments form, as in users will be able to comment about the items in my website, each individually. But its the same form for every page, which is why i need for the form to retreive the tittle of the page where it was lauch from... Its like a

    $_get and $post 

I need that when the user clicks on the link "Comment" the form would launch with the Item's Field auntofilled with the item's name which is located in the previous page... Is there a way i can say in php to retreive the Name and paste it in the next page? In php, or maybe in js or anyway... Help!

  • 写回答

4条回答 默认 最新

  • donglong2856 2013-09-19 11:40
    关注

    There are hundreds of things that may vary from what you are describing.

    Are those pages static?

    Is there a php that dynamically retrieves them from the database?

    Assuming that you already have the PHP variable that prints the title of the "item" you have, it's quite simple. You should just add a field in the form. Something like:

    <?php 
      print '<input type="hidden" name="item_title" value="'.$item_title_var.'"/>';
    ?>
    

    If your question is about retrieving the item title on each page, without having access to the real page data from PHP, then maybe you can combine the following JS and PHP:

    PHP Code:

    <?php 
      print '<input type="hidden" name="item_title_field" id="item_title_field"/>';
    ?>
    

    JS Code:

    <script type="text/javascript">
      window.onload = function() {
        var el = document.getElementById("your_item_title_id");
        document.getElementById("item_title_field").value = el.innerHTML;
      }
    </script>
    

    Just make sure that there is no actual HTML in the item title, but just the text. It would simplify things for you.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 距离软磁铁一定距离的磁感应强度大小怎么求
  • ¥15 霍尔传感器hmc5883l的xyz轴输出和该点的磁感应强度大小的关系是什么
  • ¥15 vscode开发micropython,import模块出现异常
  • ¥20 Excel数据自动录入表单并提交
  • ¥30 silcavo仿真,30分钟,只需要代码
  • ¥15 FastReport 怎么实现打印后马上关闭打印预览窗口
  • ¥15 利用3支股票数据估计其均值和方差的95%置信区间。
  • ¥15 微信小程序运行一项功能时,弹出未知错误弹框,检查代码没有问题
  • ¥15 ATAC测序生成self-pseudo replicates之前是否要进行去线粒体reads
  • ¥15 python模糊字匹配函数问题
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部