Category: JavaScript

Upload File Using AngularJS

<html> <head> <script src = “https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js”></script> </head> <body ng-app = “myApp”> <div ng-controller = “myCtrl”> <input type = “file” file-model = “myFile”/> <button ng-click = “uploadFile()”>upload</button> </div> <script> var myApp = angular.module(‘myApp’, []); myApp.directive(‘fileModel’, [‘$parse’, function ($parse) { return { restrict: ‘A’, link: function(scope, element, attrs) { var model = $parse(attrs.fileModel); var modelSetter = model.assign; […]

Bootstrap Grid

Bootstrap’s grid system allows up to 12 columns across the page.If you do not want to use all 12 column individually, you can group the columns together to create wider columns.Bootstrap’s grid system uses a series of containers, rows, and columns to layout and align content. Grid Classes The Bootstrap grid system has five classes: […]

Live Search using JavaScript

A live search is an enhanced search form that uses javascript technology to deliver results or suggestions within the same view. This is different from a regular HTML input field that is given autocomplete powers from a modern browser like Chrome, Firefox or Safari. A live search is often an input field that has been programmed to load suggestions from a […]

How to convert comma-separated string to an array using JavaScript

Here is the explanation how to use jQuery to split string with comma or jQuery split string into array by comma or jQuery split comma separated string into array with example. By using split() function in we can split string with comma or space etc. based on requirement in jQuery. Split function use a seperater […]

Common Ajax Function in Jquery and Javascript to Call Server

Ajax makes your application more flexible, you don’t need to reload or refresh the whole body for small changes, you can made changes in any part without loading page. Common Ajax function use in jquery click event, change event, blur event etc… and ajax to server call. Next common ajax function call in blur event […]

Drag and Drop Image using JavaScript

<!DOCTYPE HTML> <html> <head> <style> #div1, #div2 { float: left; width: 100px; height: 35px; margin: 10px; padding: 10px; border: 1px solid black; } </style> <script> function allowDrop(ev) { ev.preventDefault(); } function drag(ev) { ev.dataTransfer.setData(“text”, ev.target.id); } function drop(ev) { ev.preventDefault(); var data = ev.dataTransfer.getData(“text”); ev.target.appendChild(document.getElementById(data)); } </script> </head> <body> <h2>Drag and Drop</h2> <p>Drag the image […]

Read text file draw line between two points google map API using javascript

Maps can be a very powerful tool when visualizing the patterns in a dataset that is related to location in some way. This relation could be the name of a place, a specific latitude and longitude value, or the name of an area that has a specific boundary like a census tract or a postal […]

Switch Case using JavaScript

The objective of a switch statement is to give an expression to evaluate and several different statements to execute based on the value of the expression. The interpreter checks each case against the value of the expression until a match is found. If nothing matches, a default condition will be used. The break statements indicate the end of a particular case. If they […]