Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Javascript Articles
Page 3 of 534
How to use the submit button in HTML forms?
Submit button automatically submits a form on click. Using HTML forms, you can easily take user input. The tag is used to get user input, by adding the form elements. Different types of form elements include text input, radio button input, submit button, etc.Let’s learn about how to use the submit button in HTML forms. It is also created using HTML tag but type attribute is set to button.You can try to run the following code to use submit button to submit and reset a form. Under the action, attribute add the file, where you want to reach after ...
Read MoreHow to use JavaScript to redirect an HTML page?
You might have encountered a situation where you clicked a URL to reach a page X but internally you were directed to another page Y. It happens due to page redirection.It is quite simple to do a page redirect using JavaScript on the client side. To redirect your site visitors to a new page, you just need to add a line in your head section as follows.You can try to run the following code to learn how to use JavaScript to redirect an HTML page. Here, we will redirect to the homepageExample ...
Read MoreHow to use Meta Tag to redirect an HTML page?
Page redirection is a situation where you clicked a URL to reach a page X but internally you were directed to another page Y. It happens due to page redirection.To use a META Tag to redirect your site is quite easy. With this, use the http-equiv attribute to provide an HTTP header for the value of the content attribute.The following is an example of redirecting current page to another page after 2 seconds. If you want to redirect page immediately then do not specify the content attribute.Example HTML Meta Tag This is demo text.
Read MoreHow to append an item into a JavaScript array?
To append an item to a JavaScript array, use the push() method.ExampleYou can try to run the following code to append an item: var arr = ["marketing", "technical", "finance", "sales"]; arr.push("HR"); document.write(arr); Outputmarketing,technical,finance,sales,HR
Read MoreHow to create a zero-filled JavaScript array?
To create a zero-filled JavaScript array, use the Unit8Array typed array.ExampleYou can try to run the following code: var arr1 = ["marketing", "technical", "finance", "sales"]; var arr2 = new Uint8Array(4); document.write(arr1); document.write("Zero filled array: "+arr2);
Read MoreWhat is the best way to initialize a JavaScript Date to midnight?
To initialize a JavaScript Date to midnight, set hours like the following −setHours(0,0,0,0);ExampleYou can try to run the following code to set a date to midnight − var dt; dt = new Date(); dt.setHours(0,0,0,0); document.write(dt); OutputMon May 28 2018 00:00:00 GMT+0530 (India Standard Time)
Read MoreHow to get current date/time in seconds in JavaScript?
To convert time in seconds, firstly get the current time. Then, multiply the hours to 3600 and minutes to 60; rest you can see below −(hours*3600) + (min*60) + secExampleYou can try to run the following code to get the current time in seconds − JavaScript Get Seconds var dt = new Date(); var sec = dt.getSeconds(); document.write("Seconds: " + sec); var min = dt.getMinutes(); document.write("Minutes: " + min); var hrs = dt.getHours(); document.write("Hours: " + hrs); var total_seconds = (hrs*3600) + (min*60) + sec; document.write("Total seconds: " + total_seconds) ; OutputSeconds: 35 Minutes: 37 Hours: 9 Total seconds: 34655
Read MoreHow to get Euler's constant value in JavaScript?
To get Euler’s constant value in JavaScript, use the Math E property. This is a Euler's constant and the base of natural logarithms, approximately 2.718.ExampleYou can try to run the following code to get Euler’s constant value in JavaScript − JavaScript Math E Property var property_value = Math.E document.write("Property Value is :" + property_value); OutputProperty Value is :2.718281828459045
Read MoreHow to get Natural logarithm of 2 in JavaScript?
To get the Natural logarithm of 2, use the Math.LN2 property in JavaScript. It returns the natural logarithm of 2, which is approximately 0.693.ExampleYou can try to run the following code to get Natural logarithm of 2 − JavaScript Math LN2 Property var property_value = Math.LN2 document.write("Property Value is : " + property_value); OutputProperty Value is : 0.6931471805599453
Read MoreHow to create a two dimensional array in JavaScript?
A two-dimensional array has more than one dimension, such as myarray[0][0] for element one, myarray[0][1] for element two, etc. To create a two-dimensional array in JavaScript, you can try to run the following code −Example var myarray=new Array(3); for (i=0; i
Read More