默认表单字段值 [英] default form field value

查看:82
本文介绍了默认表单字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个表单,我想确保在提交表单时输入的值在表单中保持可见。这就是我所拥有的:

展开 | 选择 | Wrap | 行号

解决方案

只需检查帖子数据是否为现在,如果是,则将其回显到值。

展开 | 选择 | 包裹 | 行号


感谢。这样可行。现在我怎么能用下拉框做同样的事情?我希望它默认为发布表单时从下拉列表中选择的值。我目前有:

展开 | 选择 | Wrap | 行号


Heya,geebee。


设置< select>的值元素,您需要将''selected =" selected"''添加到正确的<选项>元素。


最简单的方法是在动态输出每个元素时处理它们:

展开 | 选择 | Wrap | 行号

hi,

i have a form and i want to be sure that when the form is submitted the value entered stays visible in the form. here is what i have:

Expand|Select|Wrap|Line Numbers

解决方案

Just check if the post data is present and, if it is, echo it into the value.

Expand|Select|Wrap|Line Numbers


thanks. that works. now how can i do the same thing with a dropdown box? i want it to default to the value already selected from the dropdown when the form is posted. i currently have:

Expand|Select|Wrap|Line Numbers


Heya, geebee.

To set the value of a <select> element, you need to add ''selected="selected"'' to the proper <option> element.

The easiest way to do this is to process each element as you dynamically output it:

Expand|Select|Wrap|Line Numbers


这篇关于默认表单字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆