Html input form shows image before uploads

Html input form shows image before uploads


11/01/2017

javascript function for responsive design

function max_width(w) {
   if(window.innerWidth <= w) {
     returntrue;
   } else {
     returnfalse;
   }
}


19/01/2016

JavaScript money format

var profits=2489.8237
  profits.toFixed(3)//returns 2489.824 (round up)
  profits.toFixed(2)//returns 2489.82
  profits.toFixed(7)//returns 2489.8237000 (padding)

29/12/2015

Javascript serializeObject function

[code] $.fn.serializeObject = function() { var o = {}; var a = this.serializeArray(); $.each(a, function() { if (o[this.name] !== undefined) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(this.value || ''); } else { o[this.name] = this.value || ''; } }); return o; }; [/code]

14/01/2015

Developing a jQuery plugin example

dd
[code]</pre> (function ( $ ) { $.fn.greenify = function( options ) { // This is the easiest way to have default options. var settings = $.extend({ // These are the defaults. color: "#556b2f", backgroundColor: "white" }, options ); // Greenify the collection based on the settings variable. return this.css({ color: settings.color, backgroundColor: settings.backgroundColor }); }; }( jQuery )); <pre> [/code]
code plugin expect an option   this in function represents  "$(selector)"
usage:   $("div").greenify({font-size:12px});
if want to  any other function for  chaining in plugin function return this;
  $("div").greenify({font-size:12px}).any_function();

14/01/2015

jquery get form value by selection or by attr function

function GetSelectedValues(selection){ return $(selection).map(function() { if($(this).val() !== "") return $(this).val(); }).get().join(","); } function GetSelectedAttr(selection,attrx){ return $(selection).map(function() { return $(this).attr(attrx) ; }).get().join(","); }

14/01/2015

jqPlot jQuery Javascript framework for plotting and charting

jqPlot is a plotting and charting plugin for the jQuery Javascript framework. jqPlot produces beautiful line, bar and pie charts with many features:

14/01/2015

Leafleft An Open-Source JavaScript Library for Mobile-Friendly Interactive Maps

An Open-Source JavaScript Library for Mobile-Friendly Interactive Maps Leaflet is a modern open-source JavaScript library for mobile-friendly interactive maps. It is developed by Vladimir Agafonkin with a team of dedicated contributors. Weighing just about 33 KB of JS, it has all the features most developers ever need for online maps.

14/01/2015

Google Maps

latitude, longitude Drawing on map marker info windows Waypoints polyline polygons Directions service Keywords : travel modes, street view      

14/01/2015

bootstrap & fancybox conflict

it can be solved by  fancy  beforeLoad
$(document).ready(function() {
 var fancy_top = "";
 $("[id^='fancy_popup']").fancybox({
 'width' : '75%',
 'height' : '75%',
 'autoScale' : false,
 'transitionIn' : 'none',
 'transitionOut' : 'none',
 'type' : 'iframe',
 'afterClose' : function() {
   document.body.scrollTop=fancy_top; 
  $('html, body').animate({ scrollTop:fancy_top });},
 'beforeLoad' : function() { 
  var fancy_top = document.body.scrollTop; 
 }

 });

 $('.fancybox').fancybox();

 });

14/01/2015

Multiple CKEditor replace by class with same class in one page

CKEditor replace  by class with same class in one page <textarea cols="80"  class="editor"   name="editor1" rows="10"> ddd</textarea> <textarea cols="80"    class="editor"  name="editor2" rows="10"> ddd</textarea>

<script>

var dd=1;
$(".editor").each(function(){

$(this).attr("id","editor"+dd);

CKEDITOR.replace( 'editor'+dd);
dd=dd+1;
});

</script>
										

14/01/2015

jQuery Conflict problem - is not a function

  TypeError: $ is not a function or Uncaught TypeError: Property '$' of object [object Object] is not a function Change  "$"  to  "jQuery"   Problem: is usually  caused by different version of jquery

14/01/2015

jQuery change select form by value

[php] function change_option_byvalue(select,value){ $(select).find("option:selected").removeAttr("selected"); $(select).find("option[value='"+value+"']").attr('selected','selected'); $(select).find("option[value='"+value+"']").trigger('click'); var selectparent =$(select).parent(); var newselect =$(select).clone(); $(select).remove(); selectparent.append(newselect); } change_option_byvalue("select[name='muslum']",21);  // it will select the option that has value of 21 by muslum21 [/php]

14/01/2015

geting js ajax json object result to console as key value with jquery $each() function

dd geting js ajax json object result to console as  key value  with jquery $each() function [php]</p> <p>var result = jQuery.parseJSON(response.responseText);<br /> //console.log(result);<br /> $.each(result, function(key, value){<br /> $.each(value, function(key, value){</p> <p>console.log(key, value);<br /> });<br /> });</p> <p>[/php]

14/01/2015

php strpos - javascript equivalent

http://phpjs.org/functions/strpos/ [php] function strpos (haystack, needle, offset) { // http://kevin.vanzonneveld.net // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: Onno Marsman // + bugfixed by: Daniel Esteban // + improved by: Brett Zamir (http://brett-zamir.me) // * example 1: strpos('Kevin van Zonneveld', 'e', 5); // * returns 1: 14 var i = (haystack + '').indexOf(needle, (offset || 0)); return i === -1 ? false : i; } strpos('Kevin van Zonneveld', 'e', 5); // return 1,14 [/php]

14/01/2015

jQuery Right click ContextMenu Plugin

jQuery ContextMenu Plugin http://www.javascripttoolbox.com/lib/contextmenu/   <script language="javascript" type="text/javascript"> $(document).on("contextmenu", "body", function(e){ alert("COPYRIGHT "); return false; }); </script>

										

14/01/2015

Enter key on html form submission

[php] <pre><script> function testfunction(){ document.Add.submit(); } </script></pre> <form action="" method="post" name="Add" id="Add"  enctype="multipart/form-data" onkeypress="if(Enter(event)==true){ return testfunction () }"> [/php] --------

14/01/2015

jQuery Validation Engine

http://www.position-relative.net/creation/formValidator/demos/demoValidators.html#

jQuery.validationEngine

Demos

Documentation

Github

Authors

Copyright(c) 2010, Cedric Dugas http://www.position-absolute.com 2.0 Rewrite by Olivier Refalo http://www.crionics.com

14/01/2015

loading a page effect

[php] <style type="text/css" id="page-css"> #loading { z-index:1000; position:absolute; width:100%; height:100%; overflow:hidden; background-color:#fff;} #loading .middle { position:absolute; width:100%; margin-top: -24px; top: 50%; height:52px; text-align:center;} #loadingBg { position:absolute; width:100%; height:100%; overflow:hidden; background-color:#fff; display:none;} #loadingBg .middle { position:absolute; width:100%; margin-top: -24px; top: 50%; height:52px; text-align:center;} </style> <script type="text/javascript" id="sourcecode"> window.onload = function() { $("#loading").delay(100).fadeOut(1000); } </script> <body> <div id="loading"> <div class="middle"> <div class="inner"> <img src="{RootDir}{TempDir}assets/css/img/yukleniyor.gif" alt="" /> </div> </div> </div> [/php]


14/01/2015

jQuery $ trim form value before submit

[php] $('form').submit(function(){ $(this).find('input:text').each(function(){ $(this).val($.trim($(this).val())); }); }); [/php]

14/01/2015

jquery list

  1. .is()
  2. .has()
  3. $.extend(obeject1, obeject2, obejectN );
  4. <script>$("td:gt(4)").css("text-decoration", "line-through");</script>
  5. .delegate()
  6. .clone() 
ajax form plugin  http://www.alajax.com/, [code] <pre>/** * ALAJAX auto sender for jQuery * Create an auto ajax sender from your basic HTML code. * @url http://www.alajax.com/ * @version 1.2 * CopyRight: GNU General Public License v2 * * Developed by: Alaa Badran * http://www.alajax.com/ * Email info@alajax.com * */ $ = jQuery; // Make sure its defined <!--more--> $.fn.alajax = function (options){ // sgObj is a holder for #gallery container.. Cashing it. var aObj = $(this); // contaciner object var aForm = ($(this).is('form') ? $(this):$(this).find('form').eq(0)); // Storing Form object var oid = $(this).attr('id'); // Storing the ID of current Object // Default settings. var settings = { type: 'text', // 'text', 'json' or 'xml' success: function(){}, error: function (){}, beforeSend: function (){}, postType: aForm.attr('method'), // Storing Form method.. POST or GET tourl: aForm.attr('action') // Storing URL to send data to }; settings = $.extend(settings, options); function _sendData(){ // Run AJAX function $.ajax({ type: settings.postType, url: settings.tourl, data: aForm.serialize(), dataType: settings.type, beforeSend: function (){ // add code here if you want to do something before sending the form settings.beforeSend(); }, success: function(data, textStatus, jqXHR){ // Add code here when send is successful. settings.success(data); }, error: function (jqXHR, textStatus, errorThrown){ //alert(errorThrown); settings.error(); } }); } /** * The initializer for this plugin. */ function _init(){ aForm.submit(function (event){ _sendData(); // Processing event.preventDefault(); // To disable form submitting. Submit will be by AJAX only using the function above. }); } return _init(); } // END of Plugin</pre> [/code]

14/01/2015