Javascript Articles

Page 3 of 534

How to use the submit button in HTML forms?

mkotla
mkotla
Updated on 11-Mar-2026 5K+ Views

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 More

How to use JavaScript to redirect an HTML page?

Rishi Raj
Rishi Raj
Updated on 11-Mar-2026 2K+ Views

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 More

How to use Meta Tag to redirect an HTML page?

Paul Richard
Paul Richard
Updated on 11-Mar-2026 13K+ Views

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 More

How to append an item into a JavaScript array?

Sravani S
Sravani S
Updated on 11-Mar-2026 293 Views

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 More

How to create a zero-filled JavaScript array?

Ramu Prasad
Ramu Prasad
Updated on 11-Mar-2026 174 Views

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 More

What is the best way to initialize a JavaScript Date to midnight?

V Jyothi
V Jyothi
Updated on 11-Mar-2026 554 Views

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 More

How to get current date/time in seconds in JavaScript?

Abhinanda Shri
Abhinanda Shri
Updated on 11-Mar-2026 731 Views

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 More

How to get Euler's constant value in JavaScript?

Kumar Varma
Kumar Varma
Updated on 11-Mar-2026 889 Views

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 More

How to get Natural logarithm of 2 in JavaScript?

Paul Richard
Paul Richard
Updated on 11-Mar-2026 542 Views

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 More

How to create a two dimensional array in JavaScript?

Nikitha N
Nikitha N
Updated on 11-Mar-2026 784 Views

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
Showing 21–30 of 5,338 articles
« Prev 1 2 3 4 5 534 Next »
Advertisements