app.js var app = angular.module('mdmApp', ['ngRoute','ngTouch', 'ui.bootstrap','angular-perfect-scrollbar-2']); app.config(function ($routeProvider) { $routeProvider .when('/', { title: 'My Deals', routeName: 'home', slideMenu: false, isSideDisabled: true, controller: 'NGMyDeals', templateUrl: 'html/NG-my-deals.html' }) .when('/advancedSearch/:edit', { title: 'Advanced Search', routeName: 'advancedSearch', slideMenu: true, isSideDisabled: false, controller: 'NGAdvanceSearch', templateUrl: 'html/NG-advance-search.html' }) .when('/createNewScenario', { title: '', routeName: 'createNewScenario', slideMenu: true, isSideDisabled: false, templateUrl: 'html/NG-create-new-scenario.html' }) .when('/advancedSearchResults', { title: 'Search Results', routeName: 'advancedSearchResults', slideMenu: true, isSideDisabled: false, controller: 'NGMyDeals', templateUrl: 'html/NG-search-results.html' }) .when('/login', { title: 'Login As Proxy', routeName: 'login', slideMenu: true, isSideDisabled: false, templateUrl: 'html/login-as-proxy.html' }) .when('/saveSearches', { title: 'Saved Searches', routeName: 'home', slideMenu: true, isSideDisabled: false, templateUrl: 'html/NG-save-searches.html' }) .when('/dealPricing', { title: 'Deal Pricing', routeName: 'dealPricing', slideMenu: true, isSideDisabled: false, templateUrl: 'html/NG-deal-pricing.html' }) .when('/components', { title: 'Components', routeName: 'components', slideMenu: false, isSideDisabled: false, templateUrl: 'html/components.html' }) .otherwise({ redirectTo: '/' }); }); ----------------------------------- controllers.js app.controller('MainController', function ($scope, $http, $location, $modal) { $scope.slideMenu = function () { $scope.slideMenuActive = !$scope.slideMenuActive; }; $scope.radioModel='LPL'; $scope.openChangeAccess = function (size) { var modalInstance = $modal.open({ animation : 'true', templateUrl : 'templates/common/changeAccess.html', controller: 'ModalInstanceCtrl', size : 'md' }); }; $scope.openAddProxy = function (size) { var modalInstance = $modal.open({ animation : 'true', templateUrl : 'templates/common/addProxy.html', controller: 'ModalInstanceCtrl', size : 'lg' }); }; $scope.openQuickLinks = function (size) { var modalInstance = $modal.open({ animation : 'true', templateUrl : 'templates/common/quickLinks.html', controller: 'ModalInstanceCtrl', size : 'lg' }); }; $scope.openDeleteRow = function (size) { var modalInstance = $modal.open({ animation : 'true', templateUrl : 'templates/common/deletePopup.html', controller : 'ModalInstanceCtrl', size : 'sm' }); }; $scope.openAppReq = function (size) { var modalInstance = $modal.open({ animation : 'true', templateUrl : 'templates/myDeals/appRequired.html', controller : 'ModalInstanceCtrl', size : 'lg' }); }; $scope.go = function ( path ) { $location.path( path ); }; $scope.typeAhead = ['Mary Williams (marywill)']; $scope.scrollopts = { wheelSpeed: 1, wheelPropagation: true, minScrollbarLength: 20 }; }); ------------------------------------------- directives.js app.directive('toggleClass', function() { return { restrict: 'A', link: function(scope, element, attrs) { element.bind('click', function() { element.toggleClass(attrs.toggleClass); }); } }; }); app.directive('selectBox', function($timeout) { return { restrict: 'E', replace: true, scope: { selected: '=', array: '=', class: '=' }, template: '', controller: ['$scope', function($scope) { $scope.changeVal = function(v){ $scope.array[0].selectedValue = v; } }] }; });
We can build a long form using php's foreach function in the following way. It makes the form more manageable and clean
<form name="myform" method="get" action="business.php" onsubmit=""> <?php $postvalue=array("Name"=>"0","Email"=>"1","Phone"=>"2"); foreach($postvalue as $key => $value) { echo ''.$key.'<input type="text" id="id'.$value.'" name="name['.$value.']" value=""><div id="err'.$value.'"></div><br>'; } ?> <input type="submit" onclick="checkValidit()"> </form>We can add any number of keys and values in array To get the values we can use following code
<?php session_start(); $value = $_GET["name"]; foreach ($value as $uni) { $_SESSION[$uni] = $uni; } foreach ($value as $uni) { echo $_SESSION[$uni] . "<br>"; } ?>
HTML FORM
<form name="myform" method="get" action="business.php" onsubmit=""> Name<input type="text" id="id0" name="name[0]" value=""><div id="err0"></div><br>Email<input type="text" id="id1" name="name[1]" value=""><div id="err1"></div><br>Phone<input type="text" id="id2" name="name[2]" value=""><div id="err2"></div><br><input type="submit" onclick="checkValidit()"> </form>jQuery Validation Code
<script type="text/javascript"> function isValidEmailAddress(emailAddress) { var pattern = new RegExp(/^([w-.]+@([w-]+.)+[w-]{2,4})?$/); return pattern.test(emailAddress); }; function isValidPhone(phone) { var pattern = new RegExp( /^d*[0-9](|.d*[0-9]|,d*[0-9])?$/); return pattern.test(phone); }; function checkValidit() { if( !$("input").val() ) { $("form").submit(function (e) { e.preventDefault(); //prevent default form submit }); } }; $(function(){ $('input').blur(function() { if($(this).attr("id")=="id1") { // alert("email"); if( !isValidEmailAddress($(this).val()) ) { $("#err1").html("Enter Valid Mail"); }else if(!$(this).val()){ $("#err1").html("Enter Mail"); } else{ $("#err1").html(""); } } else if($(this).attr("id")=="id2") { if( !isValidPhone($(this).val()) ) { $("#err2").html("Enter Valid Phone"); }else if(!$(this).val()){ $("#err1").html("Enter Phone"); } else{ $("#err2").html(""); } } else if($(this).attr("id")=="id0") { if( !$(this).val() ) { $("#err0").html("Enter Name"); } else{ $("#err0").html(""); } } }); }); </script>
index.php?paraname=VALUE1¶name=VALUE2¶name=VALUE3¶name=VALUE4Now if we get paraname parameter as follow $val = $_REQUEST['paraname']; // Output only last value VALUE4 we can bind all parameters in an array by doing a change in the form from where the values are coming like as follow
<form action="" method="get"> <input name="paraname[]"> <input name="paraname[]"> <input name="paraname[]"> <input name="paraname[]"> </form>Then we can request the values as
<php $val = $_REQUEST['paraname']; foreach ($val as &$Mvalue) { echo $Mvalue."<br>"; } ?>
<script type="text/javascript">window.onkeyup = function (event) {if (event.keyCode == 27) {document.getElementById(boxid).style.visibility="hidden";// window.close();}}</script>
$( document ).on( 'click', function ( e ) {if ( $( e.target ).closest( elem ).length === 0 ) {$( elem ).hide();}});$( document ).on( 'keydown', function ( e ) {if ( e.keyCode === 27 ) { // ESC$( elem ).hide();}});