in html, a form comprises of various elements which helps in making a user interface in a web page. using which we can collect different nature of nature.
One of the commonly used control is Month control i.e.
Executing the code given above, a month control will be displayed on the page.
When you click on the calendar icon on the right side of the control, it will open the complete month calendar like this −
一旦下拉菜单打开,您可以从日历中选择月份和年份,或者您可以在控件中输入月份和年份。
Once the month and year is selected, it will get stored in String type of value.
Let us create a program to display the selected month and year from the control using JavaScript.
Example
Admission Form function display(){ d=form1.doa.value; document.write("Date of Admission is "+d +""); }
In this program, we have used tag to write JavaScript code in which a function is created to display the selected month when onchange() event is triggered. onchange event will be fired when a date value is selected from the control. document.write() will display the value on the next page. We have displayed the date of admission in the formatted output by using formatting tags.
Admission Form function display(){ d=form1.doa.value; document.write("Date of Admission is "+d +""); }
We can also set the default value of month and year which should be displayed when the web page gets loaded in the browser. To do so, we can use value attribute in tag.
Example
Select a month:
Once this program is executed, it will show “December, 1980” as the default value in the month control.
In this program, you can observe that only December month (year 1980) is active and others are disabled and similarly when you type the year 1981, it will show you months upto November because we have set the range.
If user types the invalid month or year name, it will show an error message like this −
We can also make use of step attribute using which we can skip few months for the given year while setting the date range. Look at the example shown below of an event registration form where assuming that a particular event is falling under specific months.
Example
Live Concert Olympics in Beijing World Series(Baseball)
我们使用内联样式属性,在HTML中设置单元格填充。单元格填充是表格的单元格边框与单元格内内容之间的空间。样式属性用于HTML的 标签内,使用CSS属性padding并指定像素值。 Syntax Following is the syntax to set cell padding in HTML. …
本篇文章带大家了解一下html(超文本标记语言),介绍一下html的本质,html文档的结构、html文档的基本标签和图像标签、列表、表格标签、媒体元素、表单,希望对大家有所帮助! HTML 到底是什么? HTML 英文全称是 Hyper Text Markup Language,中文译为“超文本标…
本篇文章带大家了解一下html注释和颜色,并分享一些常用颜色名、十六进制值,希望对大家有所帮助! 一、HTML注释(附带示例) HTML 注释主要用来对文档中的代码进行解释说明,注释也是代码的一部分,但浏览器会自动忽略注释的内容,所以用户在网页中是看不到注释的。 我们在编写代码时应该善用注释,因为一…