Category: javascript

accessing checkbox using javascript

In the following example, we hide/unhide the table using checkbox. We access the checkbox using javascript. Also the code changes the textbox ‘txtname’ to readonly <!DOCTYPE html> <html> <head> <title>Untitled document</title> <meta charset="utf-8" /> <script language="javascript" type="text/javascript"> function myfunction() { var chk = document.getElementById("chkchoice1"); var tbl = document.getElementById("tbl1"); if(chk.checked == true) { // document.writeln("It is

setting target page using javascript

In the following example, the form’s action property is set dynamically using javascript. This method can help in setting the target page to which form should submit data on the run time. <!DOCTYPE html> <html> <head> <title>Untitled document</title> <meta charset="utf-8" /> <script language="javascript" type="text/javascript"> function myfunction(actionvalue) { var myform = document.getElementById("frm"); myform.action = actionvalue; //

javascript function calling

In the following example, three functions are called against three buttons with type=”button” <!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8" /> <script language="javascript" type="text/javascript"> function redColor() { document.bgColor = "red"; } function blueColor() { document.bgColor = "blue"; } function greenColor() { document.bgColor = "green"; } </script> </head> <body> <input id="btn1" name="btn1" type="button" value="Red" onclick="redColor();" /><br

Introduction to javascript

Javascript is a client-side scripting language. This means, the code written in javascript is run locally on a user’s browser and is not run on the remote server. The following file introduces code of javascript. A javascript function is called against onclick property of a button. The function assigns value of first textbox to the