WHAT'S NEW?
Loading...
Showing posts with label Bootstrap Plugins. Show all posts
Showing posts with label Bootstrap Plugins. Show all posts

bootstrap-Modal


                Bootstrap is one of the best CSS Framework widely used by developers who don’t like spend days of week for CSS coding (Most boring and difficult to maintain redundant code). Its is quite simple and flexible framework. Now developers can design light weight websites in couple of days instead of spending weeks to design website. It also provides plugins Ex, Dropdowns, Button Groups, Alerts, Process Bars and Modals.

Here Mostly developers face problem with Extensive components. Sometimes developer faces problem to pass variables in Model and save modal element values to mysql table.


Create MYSQL table as below which will be used to save modal element’s value.

CREATE TABLE IF NOT EXISTS `inward` (
  `ent_no` int(11) NOT NULL AUTO_INCREMENT,
  `inw_no` int(11) DEFAULT NULL,
  `item_code` int(11) DEFAULT NULL,
  `item_name` varchar(30) DEFAULT NULL,
  `item_rate` double DEFAULT NULL,
  `item_qty` double DEFAULT NULL,
  `item_unit` varchar(5) DEFAULT NULL,
  `item_vat` double DEFAULT NULL,
  `item_addvat` double DEFAULT NULL,
  `total` double DEFAULT NULL,
  `created_by` varchar(15) DEFAULT NULL,
  `created_date` date DEFAULT NULL,
  `edit_count` int(4) DEFAULT NULL,
  PRIMARY KEY (`ent_no`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;



STEP - 1

Create webpage named index.php and import bootstrap css & JS files in header. Download Bootstrap from here.
Create Button to call modal on `onclick` event. It is formatted by bootstrap style.

<button data-id='" . $var. "' type='button' data-toggle='modal' id='edititem' class='btn btn-outline btn-warning btn-xs'>
           Launch Modal
</button>

button
Output


`$var` is variable that we will pass to modal. `edititem` id added to button.



Step-2

Create Modal with form and form fields item_code,rate,unit,vat,additional vat..


<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">Inward Items</h4>
            </div>
            <form class="inwarditem">
                                                                           
            <fieldset>
            <div class="modal-body">
                    <input type="hidden" id="ent_no" name="ent_no" value="<?php echo $ent_no; ?>" />
                   
                    <div class="form-group">
                        <label class="form-label">Item Name</label>
                        <input class="form-control"  name="item_code" type="text" value="<?php echo $item_code; ?>"/>
                    </div>                   
                    <div class="form-group">
                        <label class="form-label">Rate</label>
                        <input class="form-control"  name="item_rate" type="text" value="<?php echo $item_rate; ?>"/>
                    </div>
                   
                    <div class="form-group">
                        <label class="form-label">Qty</label>
                        <input class="form-control"  name="item_qty" type="text" value="<?php echo $item_qty; ?>"/>
                    </div>
                   
                    <div class="form-group">
                        <label class="form-label">Unit</label>
                        <input class="form-control"  name="item_unit" type="text" value="<?php echo $item_unit; ?>"/>
                    </div>
                   
                    <div class="form-group">
                        <label class="form-label">Vat</label>
                        <input class="form-control"  name="item_vat" type="text" value="<?php echo $item_vat; ?>"/>
                    </div>
                   
                    <div class="form-group">
                        <label class="form-label">Additional Vat</label>
                        <input class="form-control"  name="item_addvat" type="text" value="<?php echo $item_addvat; ?>"/>
                    </div>
                 </div>
            </fieldset>
            </form>
           
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="button" id="submit-detail" class="btn btn-primary">Save changes</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
 </div> 

Now modal will look as

modal



STEP-3

Insert JS code at bottom of page. It will set parameter value of variable and pass it to modal. At last it will call modal .

<script>
         $(function() {
        //twitter bootstrap script
                                       $("button#submit-detail").click(function(){
                                                                $.ajax({
                                                                type: "POST",
                                                                url: "process.php",
                                                                data: $('form.inwarditem').serialize(),
                                                                success: function(msg){
                                                                       $("#thanks").html(msg)
                                                                               
                                                                },
                                                                error: function(){
                                                                                alert("failure");
                                                                }
                                                                });
                                       });
        });
    </script>

Above Code will call on `onclick` event of button and run code of `process.php`.
`data: $('form.inwarditem').serialize(), `  pass form element’s value to page with `POST` request.


STEP-4

Now, Create webpage `process.php` and past below code in it.


<?php

        $con = mysql_connect('localhost','root','');
        mysql_select_db('account',$con) or die(mysql_error());
       
        if($_POST['inw_no']){           
            $item_code       = strip_tags($_POST['item_code']);
            $item_rate       = strip_tags($_POST['item_rate']);
            $item_unit       = strip_tags($_POST['item_unit']);
            $item_qty        = strip_tags($_POST['item_qty']);
            $item_vat        = strip_tags($_POST['item_vat']);
            $item_addvat     = strip_tags($_POST['item_addvat']);

            $q = "update inward set item_code=$item_code, item_rate=$item_rate, item_unit=$item_unit, item_qty=$item_qty, item_vat=$item_vat, item_addvat=$item_addvat  where ent_no = $ent_no";   
            mysql_query($q,$con);

        }
?>

Finally it save data to mysql table.
That’s it you data is successfully save to mysql table.
For source code with Example or any queries / doubts contact me at click here







bootstrap


             For those who want to developing website and application without managing heavy duty code and get world spin in result. The popularity of twitter helped it cross over from the realm of user managed light weight website where the most boring & difficult is to maintain redundant coding.
Creating CSS framework that is flexible with latest standard and tested coding takes days of month which become project itself and as you know most of us haven’t time for it.

So, Let’s see why we should use Twitter bootstrap.


Easy to get started

Now a days there are no more designers creating their own css files same old days. But, bootstrap offers set of files can easily download and just unzip it and include all in head of HTML document. That’s now you have setoff code that save valuable time for login.

Save time

Bootstrap libraries offers ready pieces of code that fills life in website in very less time. Now designer have not to spend valuable time wasting to CSS coding.

Customizable

Bootstrap is that offers free and customizable set of code you can down you site and redesign site easily.

Redundant Code

A best aspect of bootstrap is that its code can easily update at any time in any environment no other requirement have to fulfill.

JavaScript
Bootstrap comes equipped with JavaScript libraries that go above and beyond basic structural and styling. JavaScript often becomes an integral part of a web design and developers have to pull in all elements together to see the final form flourish. With Bootstrap, a developer can easily manipulate modal windows alerts, tooltips, Scroll spy, Popover, Button, Type head, etc. The best part, however, is that Bootstrap enables you to skip writing the script altogether.
Consistency
One of the main reasons this toolset was developed was because Twitter was seeing big inconsistencies between developers working on their projects. 
Updates
Bootstrap releases their update twice in year and on other hand minor version coming out on constant basis. As soon as developer find problem, bootstrap team starts to fix it.
Integration
If you’re working on a site which is already live, but still trying to iron out the creases then Bootstrap can help. For instance, if you use table styling, all you need to do is take the styles you need and copy them to the CSS file you’re working with. 
Great Grid System
It built on responsive 12 columns, layout and components. When you need to change layout or grid, its only matter of few minutes.
Styling HTML Elements
Provides set of controls and elements with different styles which can change or manage in future.
The HTML elements for which styles are provided are:
·         Typography
·         Code
·         Tables
·         Forms
·         Buttons
·         Images
·         Icons

JavaScript Plugins

The components such as drop down menu are made interactive with the numerousJavaScript plugins bundled in the bootstrap package.

Extensive list of components

It covers extensive components like 
It covers extensive components like
·         Dropdowns
·         Button Groups
·         Navigation Menu
·         Alerts
·         Labels
·         Process bar
·         Charts
·         And so many others.



Learnable.com is best place to learn fresh skills and guidance from masters solving problem with great team with unlimited access.










In this Post we will learn to validate form controls using Jquery and PHP.
Sometime, during online form submission user must fulfil some condition to successfully submit form for example some fields must require (Eg. Username), minimum or maximum characters (Eg. Password),  some fields must be Email Id, some fields must be Numbers,  two fields Match (Eg. Confirmation emailed) , Callback, Regex  etc.  Bootstrap provides Bootstrap validation plugin for validation jqBootstrapValidation.
Here is simple Example illustrates how to use it in our existing form.

form_validation
















Index.php

<!—Import Rxternal Resources-- >
<script type=”text/javascript” src=” http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js “> </script>
<script type=”text/javascript” src=” setup.js “> </script>
<link href=”http://getbootstrap.com/dist/css/bootstrap.css”  type=”text/css”>
<!—Form -- >
<form>
    <div class="form-group">
        <label class="control-label" for="firstname">Name:</label>
        <div class="input-group">
            <span class="input-group-addon">$</span>
            <input class="form-control" placeholder="Enter UserName " name="firstname" type="text" />
        </div>
    </div>
    <div class="form-group">
        <label class="control-label" for="lastname">Email:</label>
        <div class="input-group">
            <span class="input-group-addon">€</span>
            <input class="form-control" placeholder="Enter Email Id" name="lastname" type="email" />
        </div>
    </div>
        <button type="submit" class="btn btn-primary"<Submit</button>
</form>


Here we have created simple form with fields Name and email with css classes.
For Validation we will use custom js code as below

Setup.js

    $('form').validate({
        rules: {
            firstname: {
                minlength: 3,
                maxlength: 15,
                required: true
            },
            lastname: {
                minlength: 3,
                maxlength: 15,
                required: true
            }
        },
        highlight: function(element) {
            $(element).closest('.form-group').addClass('has-error');
        },
        unhighlight: function(element) {
            $(element).closest('.form-group').removeClass('has-error');
        },
        errorElement: 'span',
        errorClass: 'help-block',
        errorPlacement: function(error, element) {
            if(element.parent('.input-group').length) {
                error.insertAfter(element.parent());
            } else {
                error.insertAfter(element);
            }
        }
    });



That’s it now form is ready with walidation. You can directly get support from Github click here provides code for each type of validation.

Download  Bootstrap Validation V1.3.6
To read more follow me on g+