Friday, July 11, 2014

Download file after form submit in PHP

In this article i am going to explain how to download after form submitted in PHP.There are two ways available to download file using php.In this example i have used both methods.

1.Using PHP
2.Using Javascript and meta tag.


readfile() is used to Outputs a file.

PHP Function

$file="test.zip";
        header('Content-type:  application/zip');
        header('Content-Length: ' . filesize('test.zip'));
        header("Content-Disposition: attachment; filename='test.zip'");
        readfile($file);

Javascript function

<script>
    $(document).ready(function(){
      window.setTimeout(function(){
        window.location = 'test.zip';
      }, 1500);
    });
    </script>

Please share your comments and feedback.Thanks.Please subscribe my updates via email.

Thursday, July 10, 2014

Show or Hide Password using jQuery

In this post i want to explain how to Show or Hide Password using jQuery.In this example i have used show() and hide() methods.This method is very useful to check wheather entered password correct or not.


Before that we need to include jQuery Library file.Copy and Paste the following URL.
Library File:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.js"></script>

jQuery Function

 <script type="text/javascript">
    $(function () {
        $('#show').hide();
      
            $('#btn').click(function () {
                var txt = $('#btn').val()
                var pwd = $('#hide').val();
                if (pwd.length > 0) {
                    if (txt == 'Show Password') {
                        $(this).val('Hide Password');
                        $('#show').val($('#hide').val());
                        $('#show').show();
                        $('#hide').hide();
                        return false;
                    }
                else if (txt == 'Hide Password') {
                    $(this).val('Show Password');
                    $('#show').hide();
                    $('#hide').show();
                    return false;
                }
            }
            else {
                    alert('Plese Enter Password');
                    return false;
                }
        });
    })
</script>

HTML File

<form>
          <div> <b>Enter Password: </b>
            <input type="password" id="hide" />
            <input type="text" id="show" />
            <input type="button" id="btn" value="Show Password" />
          </div>
     </form>


Please share your comments and feedback.Thanks.Please subscribe my updates via email.

Saturday, July 5, 2014

Display current time on webpage using Javascript

In this post i want to explain how to Display current time on webpage using Javascript.In this example i have used date and toLocaleTimeString methods.

toLocaleTimeString:
Return the time portion of a Date object as a string, using locale conventions.

Date():
The Date object lets us work with dates.

A date consists of a year, a month, a week, a day, a minute, a second, and a millisecond.

Date objects are created with the new Date() constructor.

There are 4 ways of initiating a date:
new Date()
new Date(milliseconds)
new Date(dateString)
new Date(year, month, day, hours, minutes, seconds, milliseconds)

setTimeout:
Display an alert box after xx seconds


Live DemoDownload Script

Before that we need to include jQuery Library file.Copy and Paste the following URL.
Library File:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.js"></script>

jQuery Function

<script type="text/javascript">
            function ShowTime() {
                var dt = new Date();
                document.getElementById("time").innerHTML = dt.toLocaleTimeString();
                window.setTimeout("ShowTime()", 1000); // Here 1000(milliseconds) means one 1 Sec
            }
        </script>

HTML File

<label id="time" style=" font-weight:bold"></label>

Please share your comments and feedback.Thanks.Please subscribe my updates via email.

Useful Animation jQuery CSS3 Examples

1.CSS/SVG Animated Circles
2.Endless jQuery Gallery Animation
3.Drawing Advanced animation path
4.CSS3 Parallax Fighter Jet Animation from MySkins Studio
5.CSS3 Flat Circle/Round Icon Animation
6.Animating with setTimeout
7.jquery animation effect
8.Earth orbit CSS animation
9.CSS3 Animated Bird Fly
10.CSS3 Atom Animation
11.CSS jQuery 3D Solar System
12.Pure Animated CSS birthday cake

Friday, July 4, 2014

Free Responsive HTML5 Templates

Free Responsive HTML5 Templates

Features

1.Fully Responsive and look great on smartphones, tablets, PCs.
2.Developed on HTML5 and CSS3
3.Easy Customizable
4.100% Free templates

Click here to download free templates

Please share your comments and feedback.Thanks.Please subscribe my updates via email.

Disable submit button until form fields are filled using jQuery

In this post i want to explain how to Disable submit button until form fields are filled using jQuery.This jQuery is used to check all form fields are filled are not.If fields are not filled returns false,otherwise return true.keyup() function is used to in this example.


Before that we need to include jQuery Library file.Copy and Paste the following URL.
Library File: <script type="text/javascript" src="http://code.jquery.com/jquery-1.5.js"></script>


jQuery Function

      <script type="text/javascript">
    (function() {
    $('form > input,textarea').keyup(function() {
        var empty = false;
        $('form > input,textarea').each(function() { //Check form fields are empty or filled
            if ($(this).val() == '') {
                empty = true; //result
            }
        });
        if (empty) {
            $('#send').attr('disabled', 'disabled');
        } else {
            $('#send').removeAttr('disabled');//remove disabled
        }
    });
})()
</script>

HTML File

    <form name="register" action="#" method="post">
      <table width="400" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td>Username</td>
          <td><input type="text" id="user_input" name="username" /></td>
        </tr>
        <tr>
          <td>Password</td>
          <td><input type="password" name="password" /></td>
        </tr>
        <tr>
          <td>Email</td>
          <td><input type="text" name="email" /></td>
        </tr>
        <tr>
          <td> Message</td>
          <td><textarea name="message"></textarea></td>
        </tr>
      </table>
      <input type="submit" id="send" value="Send" disabled="disabled" />
    </form>

Please share your comments and feedback.Thanks.Please subscribe my updates via email.

Thursday, July 3, 2014

Live preview using jQuery

In this post i want to explain Live preview with jQuery.This is very simple jQuery function.the keyup() is used to this example.

Syntax

$(selector).keyup()

Before that we need to include jQuery Library file.Copy and Paste the following URL.
Library File:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>

jQuery Function

 <script type="text/javascript">
        $(function()
        {
            $(".url").keyup(function()
            {
                $(".url_preview").text($(this).val()); //Get typed values and display values
            });
    });
</script>

the text() function will change the (text) value of the specified element, but keep the html structure.

HTML File

 <input type="text" name="url"  class="url" />
          <span class="url_preview" style="color:#0099FF"></span>

Please share your comments and feedback.Thanks.Please subscribe my updates via email.