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.
Function::
Complete HTML Code:
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.
Function::
Complete HTML Code:
No comments