html 表单之前的值和之后的值

发布于 2024-12-06 03:36:31 字数 801 浏览 1 评论 0原文

我想知道这是否可能: 它看起来像这样:

<tr>
  <td>
   Full Name:
  </td>
  <td>
   <input type='text' class="inputbox" name='fullname' value='<?php echo $fullname; ?>'>
  </td>
</tr>

但我想摆脱 全名 而不是输入框本身: value="Full Name"。但是函数 value=' 将回显该人输入的全名。

我的表格就是这样制作的;如果有人填写了表格,但漏掉了一个字段,则会在表格下方回显“请填写所有字段”。但如果所有的信息都要重新输入一遍那就太烦人了!这就是 value=" 发挥作用的地方。它将回显用户输入的信息。

所以我需要一个通常显示“全名”但之后的值用户输入他的全名:“John Smith”,但不是所有字段,他会得到“输入所有字段”,并且“全名”会更改为“John Smith”,

此时他将得到“John Smith” 。如果他没有进入所有领域,但我在用户输入“John Smith”之前,该字段是否也显示“全名”并且不再显示“全名”

所以换句话说,我需要两个值,一个正常显示,按下提交后它将回显。 $fullname.

我希望你们明白我的意思

I wondered if this was possible:
It looks like this:

<tr>
  <td>
   Full Name:
  </td>
  <td>
   <input type='text' class="inputbox" name='fullname' value='<?php echo $fullname; ?>'>
  </td>
</tr>

But I wanted to get rid of the <td>Full Name</td> and instead of that in the input box itself: value="Full Name". But the function value='<?php echo $fullname; ?> would echo the typed in full name of the person if he did not enter all fields.

My form is made in that way; if someone fills in the form, but leaves one field out, it will echo "please fill in all fields" under the form. But it would be annoying if he had to enter all the information over again! That's where value="<?php echo $fullname; ?> comes in. It will echo the information the user had typed.

So I need a value that shows "Full Name" normally but after a user put in his full name:"John Smith" but not all fields, he would get the "enter all fields" and the "Full Name" Would change in "John Smith".

At this moment he will get "John Smith" if he did not enter all fields, but i wan't the field too show "Full Name" before the user entered "John Smith" And NOT show "Full Name" again.

So in other words I need two values, one that shows normally, and after submit is presses it will echo $fullname.

I hope you guys understand what I mean.

Greetz

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

傲性难收 2024-12-13 03:36:31

我认为您正在寻找的是占位符...

 <input type='text' class="inputbox" name='fullname' placeholder="Your name..." />

请注意旧版浏览器不支持占位符。

I think what you are looking for are placeholders...

 <input type='text' class="inputbox" name='fullname' placeholder="Your name..." />

Please note placeholders are not supported by older browsers.

孤独陪着我 2024-12-13 03:36:31

也许您喜欢占位符?如果输入字段没有值,它将显示占位符,否则它将显示值。另一种选择是使用 if 条件:

<input name="textfield" type="text" value="<?php echo (isset($_POST["textField"]) ? $_POST["textField"] : "Full name")?> />

Maybe you like the placeholder? If the input-field has no value, it will show the placeholder, else it will show the value. Another option is working with an if-condition:

<input name="textfield" type="text" value="<?php echo (isset($_POST["textField"]) ? $_POST["textField"] : "Full name")?> />
鼻尖触碰 2024-12-13 03:36:31
<input type='text' class="inputbox" name='fullname' value='<?php echo isset($fullname) ? $fullname : 'Full Name:' ?>'>
<input type='text' class="inputbox" name='fullname' value='<?php echo isset($fullname) ? $fullname : 'Full Name:' ?>'>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文