javascript validation to check if two combo boxes has same value
Dec 8, 2009 Javascript
Suppose you have a form with 5 different combo boxes and those combo boxes have same data. Now client want that you can not select same data in 2 combo boxes.Also you have to select all 5 combo boxes. Read the rest of this entry »
How to do this by javascript. ok let me show you these 2 functions. I made these 2 functions when i faced this problem in one of my website , now i am giving this to you. Have it and enjoy the programming.
Tags: combobox, dropdown form validation, Javascript, javascript validation, validation
how to change css class name using javascript
Nov 3, 2009 Javascript
Most of the programmers don’t know about how to change css class name using javascript, specially beginners.Its very easy to change css style using javascript on any event .You just have to make a javascript function with one line and call that function on any event like onLoad , onclick etc.
suppose you want to chane css of a div when click on a button or any link.A simple div which has some text and on click on a button you want to change the border color and background color of that div.To do this first make your css class in your .css file .
Tags: border, change style, classname, css, css class, getElementById, Javascript, javascript function, onclick, reload, stylesheet
JavaScript Arrays
Oct 26, 2009 Javascript
Arrays are extremely useful for storing and manipulating information in any language.The array is one of a number of objects built directly into JavaScript. Think of them simply as variables containing multiple values. An array is a variable that can store many variables within it.In javascript arrays are same like other languages.
Values in a javascript array are accessed same as we access in php.
1.Using position (exe. myArray[2])
Creating a JavaScript Array
<script type=”text/javascript”>
<!–
var myArray = new Array();
myArray[0] = “Football”;
myArray[1] = “Baseball”;
myArray[2] = “Cricket”;
alert(myArray[0] + myArray[1] + myArray[2]);
//–>
</script>
Tags: array, array function, Array Object, Javascript, Multidimensional Arrays, Php, session array, sort, twodimensional arrays
How to hide or display content in html tag using javascript and css.
Oct 5, 2009 Javascript
We can use javascript to apply dynamic css property to hide or display html element .
document.getElementById(’testId’).style.display=’none’ // This will hide content in our element which has id “testId” Read the rest of this entry »
and
document.getElementById(’testId’).style.display=’block’ // This will show content in our element if display property is already none.
Tags: dynamic css property
Redirecting Browser to a page if JavaScript support is disabled
Oct 5, 2009 Javascript
If you have developed a page which depends on JavaScript for form validation or for any other purposes then
how can we check and how can force user to enable javascript first.
we can do this using noscript and meta tag.
1.Using <noscript> tag
2.using<meta> refresh.
Use below codes
//Code below will work when javascript is enable
<meta http-equiv=”content=type” content=”text/html charset=ISO-8859-1″ />
//Code below will work when javascript is disable
<noscript>
<meta http-equiv=”refresh” content=”0 URL=/errors/noscript.html” />
</noscript>
Make a page noscript.html to redirect user if javascript is disabled and on that page put steps about how can they enable javascript of browser.
