Archive for the ‘javascript’ Category

javascript | No Comments | July 10th, 2012

function checkAll(field) {
	for (i = 0; i < field.length; i++)
	field[i].checked = true;
}

<form  method="post" action="" name="myform">
<input type="checkbox" name="checkboxname[]" value="1">
<input type="checkbox" name="checkboxname[]" value="2">
<input type="checkbox" name="checkboxname[]" value="3">
<input name="CheckAll" type="button" value="Select All"  onclick="checkAll(document.myform['checkboxname[]'])" />
</form>

			

    						  

javascript | No Comments | June 23rd, 2012

  • 1

    Open the HTML file you want to add Javascript to in your text editor.

  • 2

    Create the Javascript tags by typing the following in the text editor: <script type=”text/JavaScript”> </script>. The tags tell the Web browser to execute the code between the tags as Javascript. The remaining code will be written between the tags.

  • 3

  • Remove the plus signs using the replace() function by writing the following code:

    myString = myString.replace(/\+/g, “”);

    Change “myString” to the name of the string you want to remove plus signs from.

  • 4

    Remove the minus signs by typing the following code:

    myString = myString.replace(/\-/g, “”);

    Substitute “myString” with the name of the string you want to remove minus signs from.

  • 5

    Save the file, then load it into a Web browser by typing the address of the file in the address bar.