Tuesday 30 July 2013

JQuery Radio Button

//To uncheck by default checked radio button

$("input:radio[name='radioButtonName']").attr("checked",false);


//To check particular radio button with starting index 0 or 1 or 2

$("input:radio[name='radioButtonName']")[0].checked = true;


//To get the value of selected radio button

$("input:radio[name='radioButtonName']:checked").val();


//To get the text(display text in radio button label) of selected radio button

$("input:radio[name='radioButtonName']:checked").parent().text();


//To get the index of selected radio buttons

var temp = $("input:radio[name='radioButtonName']");


var selectedIndex = temp.index(temp.filter(":checked"));





EXAMPLE PROGRAM
<html>
<head>
<style>

.addSelColor {
color: red;
}

.MyCssClass {
background-color: green;
cursor: pointer;
border: 2px solid yellow;
}

</style>

<script src="jquery.js"></script>
<script>
$(document).ready(function() {

  alert("Jquery is Loaded");

$("input:radio[name=sex]").change(function() {
  alert($(this).val());
  $(".radioClass").parent().removeClass("addSelColor"); //for css
  $(".radioClass:checked").parent().addClass("addSelColor"); //for css
});


$("#ClearButton").click(function() {
  $("input:radio[name=sex]").attr("checked",false);
});


$("#selectMale").click(function() {
  $("input:radio[name=sex]")[0].checked = true;
  $(".radioClass").parent().removeClass('addSelColor'); //for css
  $(".radioClass:checked").parent().addClass('addSelColor'); //for css
});


$("#selectFemale").click(function() {
  $("input:radio[name=sex]")[1].checked = true;

  $(".radioClass").parent().removeClass("addSelColor"); //for css
  $(".radioClass:checked").parent().addClass("addSelColor"); //for css
});


$("#hideButton").click(function() {
  $("#radioDiv").hide();
});


$("#showButton").click(function() {
  $("#radioDiv").show();
});


$("#getVal").click(function() {
  var temp=$("input:radio[name=sex]:checked").val();
  alert(temp);
});


$("#getText").click(function() {
  var temp=$("input:radio[name=sex]:checked").parent().text();
  alert(temp);
});


$("#getIndex").click(function() {
  var temp = $("input:radio[name=sex]");
  var selectedIndex = temp.index(temp.filter(":checked"));
  alert(selectedIndex);
});


$("#acss").click(function() {
  $("label[for=male]").addClass("MyCssClass");
  $("label[for=female]").addClass("MyCssClass");
});


$("#rcss").click(function() {
  $("label[for=male]").removeClass("MyCssClass");
  $("label[for=female]").removeClass("MyCssClass");
});


});
</script>
</head>
<body>
<div id="radioDiv">

<label for="male">
<input type="radio" class="radioClass" name="sex" value="BOY" checked>MALE<input>
</label>  
<label for="female">
<input type="radio" class="radioClass" name="sex" value="GIRL">FEMALE</input>
</label>

</div></br>

  <button id="ClearButton">Reset</button></br>
  <button id="selectMale">Male</button></br>
  <button id="selectFemale">FeMale</button> </br>
  <button id="hideButton">Hide Radio Buttons</button></br>
  <button id="showButton">Show Radio Buttons</button></br>
  <button id="getVal">Get Selected Value</button></br>
  <button id="getText">Get Selected Text</button></br>
  <button id="getIndex">Get Selected Index</button></br>
  <button id="acss">ApplyCss</button></br>
  <button id="rcss">RemoveCss</button></br>

</body>
</html>

Saturday 13 July 2013

Different ways to work with jQuery...

->First we have to download/copy JQuery code(In this blog already link is available).
->Place that code in one text file and save with the extension .js(Ex->jquery.js)
->create one html file and give this jquery.js file path in script tag(<script src="jquery.js"></script>)
->write jquery code in the script tag
->We can use following ways to work with JQuery
   
$(document).ready(function(){

         alert("WELCOME TO JQUERY");
         //write JQuery code here

});
jQuery(document).ready(function() {

         alert("WELCOME TO JQUERY");
         //write JQuery code here

});
window.jQuery(document).ready(function() {

         alert("WELCOME TO JQUERY");
         //write JQuery code here

});
window.$(document).ready(function() {

         alert("WELCOME TO JQUERY");
         //write JQuery code here

});
$(function() {

         alert("WELCOME TO JQUERY");
         //write JQuery code here

});
jQuery(function() {

         alert("WELCOME TO JQUERY");
         //write JQuery code here

});
//We can use any name instead of $
var ram=$.noConflict();
ram(document).ready(function() {

         alert("WELCOME TO JQUERY");
         //write JQuery code here

});
var ram=$.noConflict();
ram(function() {

         alert("WELCOME TO JQUERY");
         //write JQuery code here

});
var ram=$.noConflict();
window.ram(document).ready(function() {

         alert("WELCOME TO JQUERY");
         //write JQuery code here

});
var ram=$.noConflict();
window.ram(function() {

         alert("WELCOME TO JQUERY");
         //write JQuery code here

});

EXAMPLE PROGRAM
<html>
<head>
<script src="jquery.js">
</script>
<script>
    $(document).ready(function() {
         alert("AFTER LOAD THE PAGE THIS JQUERY CODE IS EXECUTING");
         //WRITE ANY JQUERY CODE
    });
</script>
</head>
<body>
HOW TO WORK WITH JQUERY
</body>
</html>

Saturday 6 July 2013

All Java Versions

J2SE:

            JDK 1.0 (January 21, 1996) Java Development kit

            JDK 1.1 (February 19, 1997)

            J2SE 1.2 (December 8, 1998) Java Standard Edition

            J2SE 1.3 (May 8, 2000)

            J2SE 1.4 (February 6, 2002)

            J2SE 5.0 (September 30, 2004)

            Java SE 6 (December 11, 2006)

            Java SE 7 (July, 2011)

            Java SE 8 (March, 2014)

            Java SE 9 (Sep 21, 2017)

            Java SE 10 (March 20, 2018)

            Java SE 11 (Sep 25, 2018)

            Java SE 12 (March 19, 2019)

            Java SE 13 (Sep 10, 2019)

J2EE:

            JPE (May 1998) Java Professional Edition

            J2EE 1.2 (December 12, 1999) Java Enterprise Edition

            J2EE 1.3 (September 24, 2001)

            J2EE 1.4 (November 11, 2003)

            Java EE 5 (May 11, 2006)

            Java EE 6 (Dec 10, 2009)

            Java EE 7 (May 28, 2013)

            Java EE 8 (Aug 31, 2017)


Differences between Java Compiler,JIT Compiler,Java Interpreter



Java Compiler->Java compiler just convert .java programs into .class files,

                   that means converting our source code into byte code.

JIT Compiler->JUST IN TIME COMPILER is the part of the Java Virtual Machine (JVM)

                   that is used to speed up the execution time. JIT compiles parts of the byte code

                   that have similar functionality at the same time, and hence reduces the amount of

                   time needed for compilation. Here the term “compiler” refers to a translator from

                   the instruction set of a Java virtual machine (JVM) to the instruction set of a specific CPU.

Java Interpreter->JAVA INTERPRETER converts total Byte code into machine dependent code,

                   If JVM use only interpreter the performance of JVM will slow,

                   so JVM uses JIT compiler and Interpreter both.


Differences between JDK,JRE and JVM



JDK->JAVA DEVELOPMENT KIT is used to develope the java programs,

         It creates the environment in our machine to develope java programs.

         JDk includes compiler,this compiler converts our source code(.java) to byte code(.class).

JRE->JAVA RUNTIME ENVIRONMENT is used to run the java programs(.class).

         JRE is the implementation of JVM,So JVM internally uses JRE to execute programs.

JVM->JAVA VIRTUAL MACHINE convert byte code to different machine dependent codes,

         JVM interanlly uses JRE.JRE is the implementation of JVM,

         JVM implementation is depends on OS.

      ->Responsibilties of the JVM

         To load the code

         To verify the code

         To Convert the code

         Execute the code


How the Java Programs are Executing?



->First our program(.java) will convert into byte code(.class) by using java compiler.

->After that Byte code(.class) will convert into machine dependent code by using JVM,

     JVM internally uses JIT compiler and INTERPRETER.


Thursday 4 July 2013

JQuery

What is JQuery?

      The purpose of jQuery is to make it much easier to use JavaScript

      and change the way that you write javascript on your website.

      jQuery also simplifies a lot of the complicated things from JavaScript,

      like AJAX calls and DOM.

The jQuery library contains the following features:

      HTML/DOM manipulation

       CSS manipulation

      HTML event methods

      Effects and animations

      AJAX

      Utilities

Benefits of using jQuery:

       Search Engine Optimized

            While search engines are getting better at being able to read content

            within some Flash, everything within jQuery is setup as text.

            This means it is completely readable to all the search engines,

            exposing all your keyword rich content.

      Save Time

            Five lines of jQuery are equivalent to 25 lines of conventional JavaScript code.

            This means smaller files and faster loading web pages.

      Plug-ins

            There are an abundance of plug-ins on the web that make creating special

            effects simple and fast for web developers.

      Help?

            With an abundance of plug-ins comes with an abundance of help.

            There is a large helpful support community on the web to help

            you quickly remedy any bug issues.

      That was easy!

            jQuery has easy implementation for web developers in comparison to other applications.

      Cross Browser Friendly

            jQuery is currently the most popular JavaScript library and works in all browsers.

      FREE!

            free, open source software.

      Mobile Devices

            jQuery is supported by any mobile device whose web browser supports JavaScript.

            A lot of mobile devices like iPads and iPhones don’t run Flash at all.

      Simplifies AJAX

      Wow Factor

            Web developers use jQuery to make web pages more exciting, interactive,cleaner,

            and more user friendly. Make your users go WOW!

Following are developed based on JQuery:

            Rotating Image Slider

            Interactive Google Map

            Animated Content Menu

            Slide Effects

            Slide Gallery

            Photobar Galler

            Slide show Gallery

            Mobile Image Gallery WebApp

            Photo Zoom out Effect