开发者

Reading inputs from HTML forms

When I found that I could clear a search box like this:

<input type='text' name='search' value='Search Here' onfocus='if (this.value == "Search Here")this.value = ""' />

It brought up two questions.

1) what language is this in? Are if statments built 开发者_StackOverflow社区with HTML or javascript?

2) is there a way for a text input to mirror the value of another? (maybe value='id.value';)


The language you are seeing is inline javascript, considered deprecated. It is better to have the handler inside a script.

If you need a refresher on javascript, see: https://developer.mozilla.org/en/A_re-introduction_to_JavaScript


That language is called drums javascript. If you don't know, I'd suggest you take a look at jQuery, a javascript library that simplifies a bunch of tasks.

You can do many other things not just mirror values. You can add new elements, move old elements, get off-page data.

What can I say? Welcome to web development.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜