Jquery

How to check whether the Radio Button is selected or not in Jquery?

<script>
function Check()
{
    var gen = $("input[@name='gen']:checked").val();
    if(!$("input[@name='gen']:checked").val())
    {
        alert('Please Select Gender');
    }
    else
    {
        alert(gen);
    }
   
}
</script>
<input type="radio" name="gen" value="Male" id="gender">Male<br>
 <input type="radio" name="gen" value="Female" id="gender">Female<br>
 <input type="button" value="Check Gender" name="check" onclick="return Check();"/>
----------------------------------By Happy Group--------------------------------------

How To Send PHP value On another Page Using JQuery

Step 1:-
<script>
function getName()
    {
        var empId = $('#empId').val();
        //alert(empId);
        $.post('query.php',{filter:'dynaminselect', stype:empId}, function(data)
        {
            //alert(data);
             var result = data;
             //alert(result);
             str1 = result;
            $('#divshow').html('');
            //$('#divshow').html(data); // display value on webpage using jquery
            $('input:text[id$=EmpName]').val(str1); // display value in textbox using jquery
        });
    }
</script>
<select id="empId" name="empId"onchange="return getName();">
        <option value="">Emp Id</option>
    <option value="105">105</option>
    <option value="101">101</option>
    <option value="1032">1032</option>
    <option value="1031">1031</option>
    <option value="143">143</option>
    <option value="1254">1254</option>
    <option value="1234">1234</option>
    <option value="2123">2123</option>
    <option value="1">1</option>
    <option value="123">123</option>
    <option value="2">2</option>
</select>
Employee Name:<input type="text" name="EmpName" id="EmpName" class="input" size="24" tabindex="2" readonly="readonly"/><!--This Value Will Get By Jquery -->

Step 2:-
<?php
if($_REQUEST['filter'] == 'dynaminselect')
{
 //echo $_REQUEST['stype']; //Value Which We Sent
 $recVal =  $_REQUEST['stype'];
 $recVal  = "Happy Group";
echo $recVal;
 
/*--------Some Time We Have To Work With Database That TIme We Can Use Following Ex--------*/
<?php
if($_REQUEST['filter'] == 'dynaminselect')
{
//echo $_REQUEST['stype']; //Value Which We Sent
//$sql = 'select * from t_employee where emp_code = "'.$_REQUEST['stype'].'"';
//echo $sql;
$query = mysql_query('select * from t_employee where emp_code = "'.$_REQUEST['stype'].'"');
//echo $query;
$row = mysql_fetch_array($query);
echo $row['fname'];
 }
?>
----------------------------------By Happy Group--------------------------------------

From Validation In Jquery

<html>
<head>
<title>Learn Form Validation In Jquery with http://learnphp4mmanoj.blogspot.com</title>
function formvalid()
{
    var empName = $('#empName').val();
    if(empName == '')
    {
        alert('Please Enter Name');
        $('#empName').focus();
        return false;
    }
     var Education = $('#Education').val();
     if(Education == '0')
    {
        alert('Please Education Details');
        $('#Education').focus();
        return false;
    }
    var gen = $("input[@name='gen']:checked").val();
    if(!$("input[@name='gen']:checked").val())
    {
       alert('Please Select Gender');
       return false;
    }
}
</head>
<body>
<input type="text" name="empName" val="empName">
 <select id="Education" name="Education">
                    <option value="0">- Select -</option>
                    <option value="4">BE / B Tech</option>
                    <option value="5">BCA</option>
                    <option value="6">Aeronautical Engineering</option>
                    <option value="8">B Arch</option>
                    <option value="9">B Plan</option>
</select>
<input type="radio" name="gen" value="Male" id="gender">Male<br>
 <input type="radio" name="gen" value="Female" id="gender">Female<br>
<input type='button' value='Check' onclick='return formvalid();'>
</body>
</html
----------------------------------By Happy Group-------------------------

2)From Validation In Jquery some easy way

<html>
  <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
  <script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
  <script>
  $(document).ready(function(){
    $("#myform").validate({
  groups: {
    username: "fname lname mname"
  },
  errorPlacement: function(error, element) {
     if (element.attr("name") == "fname" || element.attr("name") == "lname" || element.attr("name") == "mname")
       /*error.insertAfter("#mname");*/ //this statement display error messange after last name field
       error.insertAfter("#lastname");
     else
       error.insertAfter(element);
   },
   debug:true
 })
  });

</script>
</head>
<body>
<form id="myform">
<label>Your Name</label><br>
<input  id="fname" name="fname" class="required"><br>
<input id="mname" name="mname" class="required"><br>
<input id="lastname" class="required" name="lname"><br>
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
 ----------------------------------By Happy Group-------------------------

3)From Validation In Jquery in more easy way


<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
 
  <script>
  $(document).ready(function(){
    $("#myform").validate({
   errorLabelContainer: "#messageBox",
   wrapper: "li",
   submitHandler: function() { alert("Submitted!") }
})
  });
  </script>
 
</head>
<body>
  <script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
<ul id="messageBox"></ul>
 <form id="myform" action="" method="post">
   <label>First Name</label>  <br/>
   <input name="fname" class="required" />  <br/>
   <label>Middle Name</label>  <br/>
   <input name="mname" title="Middle Name"class="required" />  <br/>
   <label>Last Name</label>  <br/>
   <input name="lname" title="Last Name" class="required" />  <br/>
   <br/>
   <input type="submit" value="Submit"/>
 </form>
</body>
</html>
  ----------------------------------By Happy Group-------------------------

How To Count Multiple Selected Item in of Select Box Using JQuery

<script src="jquery-latest.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
    $('#selSkill').live('change', function(){
    var count = $("#selSkill :selected").length;
     alert(count);
    });
});

Count No Of Selected Items
<form method="post" action="">
<select name="selSkill[]" size="3" multiple="multiple" id="selSkill">
<option value="Ajax">Ajax</option>
<option value="Apache Server">Apache Server</option>
<option value="ASP">ASP</option>
<option value="C">C</option>
<option value="C++">C++</option>
<option value="Cobol">Cobol</option>
<option value="Database applications">Database applications</option>
<option value="Drupal">Drupal</option>
<option value="EJB">EJB</option>
<option value="Hardware">Hardware</option>
<option value="Hibernate">Hibernate</option>
<option value="HTML,DHTML">HTML,DHTML</option>
<option value="IIS5.0">IIS5.0</option>
<option value="Java">Java</option>
<option value="JavaScript">JavaScript</option>
<option value="Joomla">Joomla</option>
<option value="JQuery">JQuery</option>
<option value="JSP">JSP</option>
<option value="Mysql">Mysql</option>
<option value="Networking/protocols">Networking/protocols</option>
<option value="Operating systems">Operating systems</option>
<option value="Oracle">Oracle</option>
<option value="Pascal">Pascal</option>
<option value="PEAR">PEAR</option>
<option value="Pearl">Pearl</option>
<option value="Python">Python</option>
<option value="Servlet">Servlet</option>
<option value="Struts">Struts</option>
<option value="Technical certifications">Technical certifications</option>
<option value="Turbo Pascal">Turbo Pascal</option>
<option value="Visual Basic 6.0">Visual Basic 6.0</option>
<option value="Web applications">Web applications</option>
<option value="Web logic">Web logic</option>
<option value="Xml">Xml</option>
<option value="XMLLib">XMLLib</option>
<option value="XSL/ XSLT">XSL/ XSLT</option>
<option value="Zend Framework">Zend Framework</option>
</select>
<input type="submit" name="sub1" />

</form>
----------------------------------By Happy Group-------------------------

How To Find Length Of Multiple Select Box Using JQuery

<script src="jquery-latest.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
    $('#selSkill').live('change', function(){
      selected_tems = $(this).find('option').length;
     alert(
selected_tems);
    });
});
</script>

----------------------------------By Happy Group-------------------------