简体   繁体   English

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

[英]Getting a value from text input field, then displaying on 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? 使用Ajax自动选择选择选项后,我可以使该值显示在第二个文本字段中,但是如何将显示的值存储到变量中以在发布时显示呢? 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. 非常感谢您的帮助。

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. 它应该工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM