Auto fill form using JavaScript Function

Most of the developers use JavaScript getElementById() Method to get the element id and setting its value.

If form having only 2 to 3 fields then its OK to use it, but if form have number of fields then using the above style is not good as we are repeating same piece of code again and again.

To tackle this we can create a function using JavaScript and provide two parameter id and value.

The job of this function will be to set the values provided to it.

Lets understand with an example. Below is a JavaScript function.


Complete HTML Code:

Hi! I am Sartaj Husain. I am a Professional Software Developer, live in Delhi. I write blogs in my free time. I love to learn and share the knowledge with others because it is no good to try to stop knowledge from going forward. So free posts and tutorials. more..

No comments