Tuesday, December 11, 2012

how to slider bar open using jquery

-----------------------------------------------------------------------------------------------
 <script type="text/javascript" src="<?php bloginfo( 'template_url' ); ?>/js/jquery.min.js"></script>

<script type="text/javascript">
    $(document).ready(function(){
        jQuery(".pull_feedback").toggle(function(){
                jQuery("#feedback").animate({left:"0px"});
                return false;
            },
            function(){
                jQuery("#feedback").animate({left:"-527px"});  
                return false;
            }
        ); //toggle
    }); //document.ready
    </script>
-------------------------------------------------------------------------------------------------
<script language="javascript">
function processForm(formId) {
document.getElementById('process').style.display='block';
$.ajax({
type: "GET",
url: "form_ask.php",
data: "sendmsg="+document.getElementById('user_question').value,
success: function(msg)
    {
            //alert(msg);
            document.getElementById('process').style.display='none';
            $('#message').html(msg);
            $('#user_question').val('');
            return true;
    },
    error: function(){
          
            return false;
        //alert('some error has occured...');  
    },
    start: function(){
        alert('ajax has been started...');  
    }
});
}
</script>

--------------------------------------------------------------------------------------------------
<div id="feedback">
<h2>Sikh  Counseling</h2>

<form action="" id="form1" method="post"  onsubmit="processForm('form1');return false;">
<div style="clear:both; padding-bottom: 8px;"></div>
            <div id="message"></div>
            <div id='process' style="display:none"><img src="loading.gif" ></div>
       
           
            <p>           
            <textarea id='user_question'  onfocus="if(this.value=='Type Your Sikh Counseling Question Here...') this.value='';" onblur="if(this.value=='') this.value='Type Your Sikh Counseling Question Here...';">Type Your Sikh Counseling Question Here...</textarea>           
            </p>
            <p class="txt">Sikh Counselors are Online Now</p>
            <p>
            <input type='submit' name='submit' value='submit' class="btn"/>
           
            </p>
        </form>
        <a href="#" class="pull_feedback" title="Click to leave Question">Question</a>
    </div>
------------------------------------------------------------------------------------------

Friday, December 7, 2012

javascrpt captcha

<html>
<head>
<title>Captcha</title>
   
    <script type="text/javascript">

   //Created / Generates the captcha function   
    function DrawCaptcha()
    {
       var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
       var string_length =6;
       var randomstring = '';
    for (var i=0; i<string_length; i++) {
        var rnum = Math.floor(Math.random() * chars.length);
        randomstring += chars.substring(rnum,rnum+1);
          }
      
        document.getElementById("txtCaptcha").value = randomstring
    }

    // Validate the Entered input aganist the generated security code function  
    function ValidCaptcha(){
        var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
        var str2 = removeSpaces(document.getElementById('txtInput').value);
        if (str1 == str2)
           return true;       
        else
        {
            alert("Invalid captcha value");
        return false;
        }
       
    }

    // Remove the spaces from the entered and generated code
    function removeSpaces(string)
    {
        return string.split(' ').join('');
    }
   

    </script>
   
   
   
</head>
<body onLoad="DrawCaptcha();">
<table>
<tr>
    <td>
        Welcome To Captcha<br />
    </td>
</tr>
<tr>
    <td>
        <input type="text" id="txtCaptcha" disabled="true"
            style="background-image:url(captcha_bg.jpg); text-align:center; border:none;
            font-weight:bold; font-family:Arial, Helvetica, sans-serif; font-size:16px;line-height:12px;" />
        <input type="button" id="btnrefresh" value="Refresh"  onClick="DrawCaptcha();return false;" />
    </td>
</tr>
<tr>
    <td>
        <input type="text" id="txtInput"/>   
    </td>
</tr>
<tr>
    <td>
        <input id="Button1" type="button" value="Check" onClick="alert(ValidCaptcha());"/>
    </td>
</tr>
</table>
</body>
</html>