开发者

saving values from an input field

hi Iam trying to create a wordpress plugin option page.I need to create a form with input fields having default values in it and when I change the value and save it, the changed value should be reflected in the input filed and also in the variable which are assigned to store the value.

let me be more pr开发者_如何学编程ecise

When i change the value of the input field and save it it should be stored in the assiged variable value( permanently till i again change it myself).

Iam a bit poor in form validation and php.help me out guys.


If you're OK with it only working in newer browsers, you could use the placeholder attribute on the text field, to supply a placeholder that will disappear when you focus and reappear when you blur.

<input type="text" name="txtfield" value="" placeholder="input your text" />

If you want it to work in older browsers, do it in javascript:

<input type="text" name="txtfield" onfocus="if(this.value=='Enter Email')this.value=''" onblur="if(this.value=='')this.value='Enter Email'" >

Then you can use <?php $value = $_post['txtfield'] ?> to assign the input value to a variable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜