Category: javascript

A timer function in PHP using javascript

In the following example, a timer function is designed. The user need to provide input of timer function, as the timer proceeds, the color of progress bar is changing. <html> <head> <title></title> <script language="javascript" type="text/javascript"> var id = null; function myStartFunction(totalTime) { var txtbox = document.getElementById("txtbox"); var mytable = document.getElementById("mytable"); var width = 0; id

difference between calling objects of select, listbox, radiobutton array, and checkbox in javascript

What is the difference between calling objects of Select, Listbox, Radiobutton array, and checkboxes array in javascript ============================ If you have Select, it will be accessed in javascript like this: var country = document.getElementById(“ddlcountry”);… if( country.selectedIndex == 0) { alert(“Country must be selected”); return false; } To retrieve values and text of select, we use

a javascript program to compute grade from a range of marks

In the following program, the user inputs his/her marks in a text box. The GPA is computed and shown in other box index.html <!DOCTYPE html> <html> <head> <title>Untitled document</title> <meta charset="utf-8" /> <script language="javascript" type="text/javascript"> function calculategpa() { var marks = document.getElementById("txtmarks").value; var gpa = document.getElementById("txtgpa"); if(marks >= 50 && marks <= 60) { gpa.value

How to dynamically add/delete text boxes using javascript

We can dynamically insert/delete text boxes in a web page. To do so, we can put text boxes (or any other form element) into a table and dynamically delete the rows of table (or add new rows in table). <html> <head> <script language="javascript" type="text/javascript"> function Delete() { document.getElementById("myTable").deleteRow(0); } </script>   </head> <body> <table id="myTable"

creating a custom popup in javascript

When we create a popup using javascript, we can provide a list of options to customize the appearance of popup window. In the following files, a popup is created. In the popup window, user is provided with options to input values. When the user clicks on close button on popup, the values are written on

disabling back button using javascript

By default browsers does not allow us to disable back button. However, when working with database applications, we often need to disable the back button. In this example, we disable the back button using javascript: <html> <head></head> <body> <h1>This is page 1</h1> <br><br> <input id="btnback" name="btnback" type="button" value="Back" onclick="window.history.back();" /> </body> </html>  

Controlling page navigation using javascript

In this example, we control the navigation dynamically using javascript <html> <head> <title></title> <script language="javascript" type="text/javascript"> function navigate() { window.location.href="page1.html"; } </script> </head> <body > <input id="btn" name="btn" type="button" value="click here" onclick="window.open('meta.html');" /> <input id="btn1" name="btn1" type="button" value="Go to Page1" onclick="window.location.href='page1.html';" /> <br /> <a href="page1.html">Page1.html</a> <br /> <a href="javascript:;" onclick="window.location.href='page1.html';">Page1.html</a> <br /> <a href="javascript:;"

accessing status bar using javascript

In this code script, we access the status bar using javascript. The status bar shows URLs and text when mouse is move over the hyperlinks. The status bar is present at bottom left of page. <html> <head> <title></title> <script language="javascript" type="text/javascript"> function statusBarText() { window.status = "This is text"; document.write(window.status); } </script> </head> <body onload="statusBarText();">