douyu2817 2015-06-13 16:53
浏览 69
已采纳

从文本输入字段获取值,然后在POST上显示

I'm trying to get a value from a form, then display it on posting of the form. I can get the value to appear in the second text field, once I have chosen an option using the Ajax Auto-Select, but how do I get that value shown stored into a variable for display on posting? This is what I have been trying -

if ($_POST['action'] == 'getentity') {
    $value= $entity;
    $content .= '<div>'.$value.' hello</div>';
    }

<form method="post" action="?">
 <input type="text" name="TownID_display" size="50" onkeyup="javascript:ajax_showOptions(this,\'getEntitiesByLetters\',event)">
<input type="text" name="TownID" id="TownID_display_hidden" value="'.$entity.'" />
<input type="hidden" name="action" value="getentity" />
<input type="submit" name="submit"  value="Find"/>

Many thanks for any help.

  • 写回答

1条回答 默认 最新

  • dpoh61610 2015-06-13 16:59
    关注

    Try

    <input type="text" name="TownID" id="TownID_display_hidden" value="<?php $value = $entity; echo $entity; ?>" />
    

    and its better to use like this

    if ($_POST['action'] == 'getentity') {
        $value= $_POST['TownID'];
        $content .= '<div>'.$value.' hello</div>';
        }
    

    it should work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请问为什么我配置IPsec后PC1 ping不通 PC2,抓包出来数据包也并没有被加密
  • ¥200 求博主教我搞定neo4j简易问答系统,有偿
  • ¥15 nginx的使用与作用
  • ¥100 关于#VijeoCitect#的问题,如何解决?(标签-ar|关键词-数据类型)
  • ¥15 一个矿井排水监控系统的plc梯形图,求各程序段都是什么意思
  • ¥15 ensp路由器启动不了一直报#
  • ¥50 安卓10如何在没有root权限的情况下设置开机自动启动指定app?
  • ¥15 ats2837 spi2从机的代码
  • ¥200 wsl2 vllm qwen1.5部署问题
  • ¥100 有偿求数字经济对经贸的影响机制的一个数学模型,弄不出来已经快要碎掉了