Tutorial for Type Attribute in php

What is Type Attribute?

It indicates the type of input element. It’s an empty tag. The default value is text.

Example:-

<input>

<input type=“text”>
  • Text – It defines a single-line text field.
<input type=“text”>
  • Password – A password field is like text field, the difference being that this control hides each typed character by displaying an asterisk(*) or bullets(●) instead of the character itself.
<input type=“password”>
  • Button – This is used to add a button on a web form to activate a script when an user click the button.
<input type=“button”>
  • Email – This field is used to add an email address or a list of email address to a form, where type=“email” is a value for the input type. The input format should be an email like example@gmail.com else it will prompt an error.
<input type=“email”>
  • Check Box – A check box is a small box, which when selected includes a checkmark. It is used to allow the user to select one or more than one of the options available on a web page. An User can select or clear the check box by clicking it
<input type=“checkbox”>
  • Radio Button – A radio button is used to create a series of options of which only one can be selected. It is displayed as a circle which when selected, displays a dot in the middle.
<input type=“radio”>
  • URL – The URL field is used to enter only the web addresses, in their correct format. If the URL is not entered in the correct format then the URL field validates the text field to enter web address.
<input type=“url”> 
  • Autofocus – helps in keeping the focus of mouse pointer on the input field.
  • Pattern – defines the regular expression of the text that should be entered in the text field.
  • Search Box – This is used to add a search box to a form.
<input type=“search”>
  • Tel – The tel type represents a one-line plain-text edit for entering a telephone number.
<input type=“tel”>
  • Range – Range input represents the input of limited range numerical values.
<input type=“range”>
  • Number – Number is used to validate the textbox only if the value within the field is a numerical value.
<input type=“number”>
  • File – This is used to upload a file on a web page. You also need to set the enctype=“multipart/form-data”
<input type=“file”>
  • Image – It represents either an image from which the UA enables a user to interactively select a pair of coordinates and submit the form, or alternatively a button from which the user can submit the form.
<input type=“image”>
  • Hidden – A hidden control stores the data that is not visible to the user on a web page. This control is used to submit some information, which can not be edited by user.
<input type=“hidden”>
  • Submit – A submit button is used to transfer form data to the URL specified in the <form action> tag.
<input type=“submit”>
  • Reset Button – A reset button helps user to clear all the data that they have entered in the text fields.
<input type=“reset”>

  • Date – This is used for input fields that should contain a date.
<input type=“date”>
  • Time – It allows the user to select a time.
<input type=“time”>
  • DateTime – It allows the user to select  date and time.
<input type=“datetime”>
  • Datetime-local – It allows the user to select a date and time.
<input type=“datetime-local”>
  • Month – It allows the user to select a month and year.
<input type=“month”>
  • Week – It allows the user to select a week and year.
<input type=“week”>
  • Color – It is used for input fields that should contain a color.
<input type=“color”>
Tagged : / / / / / /

How to Export Html Table to Excel Sheet using JavaScript

Steps to Export HTML Table Data to Excel using JavaScript

  1. HTML Table Data:
  2. JavaScript Code:

1. HTML Table Data

Export HTML data in Excel, even before we have to load some data into an HTML table. So here we have to make fetch employee table data and load it in an HTML table with table columns like name, address, gender, designation, and age. Here we have created an HTML table with id employee_data. So this id we will use for fetch this HTML table data in JavaScript code. Under this HTML code, we have made one button tag with id export_button, so when use has clicked on this button, then HTML table data will be download in Excel file format without refresh of a web page using JavaScript.

2. JavaScript Code

In this tutorial, we have to use SheetJS JavaScript Library to export HTML table data to Excel using JavaScript. So first we have to include the following SheetJS library link at the header of this HTML web page.

In the JavaScript code part, first we have created the html_table_to_excel(type) function. This function has used sheetJS library function and convert or write HTML table data to excel format and download it in a browser without refreshing the web page.

Once a function is ready then we have to call html_table_to_excel(type) function on the button click event, so for the trigger button click event, we have to use the addEventListener method. So when a user has clicked the button the html_table_to_excel(type) function is called with the xlsx file type. Then it will download the HTML table data in .xlsx format Excel file in the browser without having to refresh a Web page on the client-side.

Tagged : / / / /