Posts

Showing posts from April, 2014

jquery code to add more and remove multiple input fields recursively

This code used to append more input fields and remove input fields recursively. div with input fields to add more and remove <div id="phone_number_form" class="hidden"> <p> Phone number : <input type="text" name="phone_number"> first name : <input type="text" name="firstname"> <input type="button" id="remove_phone_number" value="Remove"> </p> </div> <form> <p> <input type="button" value="Add phone number" id="add_phone_number"> </p> </form> css to hide the class hidden of div .hidden {     display: none; } /* Bellow is completely unnecessary */ * { font-family: Arial; font-size: 13px; } javascript code with onlick to add more and remove input fields $(document).ready(function(){     var phone_number_form_index=0;     $(&quo

change checkbox value using ajax

I was working on jqgrid changing the status 0 and 1 in database by checking the the checkbox in grid.Problem i faced was as check the checkbox it update value through ajax,but it doesnt change value in checkbox for it needed to refresh the page.What i did is got response of status through ajax and change value of checkbox using                      var checkbox = $( "#"+status_id ); var ns = checkbox.val( checkbox[0].checked ? "1" : "0" ); i was getting the checkbox as json from php In which you can find example in jqgrid with php. sample code passed through json: <input type='checkbox' name='status'  id='status_".$temp."'  value='0' onchange='pathwaystatus($temp)' /> function to change status: function pathwaystatus(e) { //alert(e); var status_id = "status_"+e; //alert(status_id); var chkbxval = document.getElementById(status_id).value; //alert(chk

api key generator in php

This function is used to create api key randomly,which can be used as password or as an apikey in php.I used this function in slim framework api. <?php function generateApiKey() { return md5(uniqid(rand(), true)); } echo generateApiKey(); ?>

jquery coding standard

Introduction Anybody can write code. With a few months of programming experience, you can write 'working applications'. Making it work is easy, but doing it the right way requires more work, than just making it work. Believe it, majority of the programmers write 'working code', but not ‘good code'. Writing 'good code' is an art and you must learn and practice it. Everyone may have different definitions for the term ‘good code’. But the following are the characteristics of good code. Reliable Maintainable Efficient Most of the developers are inclined towards writing code for higher performance, compromising reliability and maintainability. But considering the long term ROI (Return On Investment), efficiency and performance comes below reliability and maintainability. If your code is not reliable and maintainable, you will be spending lot of time to identify issues, trying to understand code etc throughout the life of your application.

Install phonegap in ubuntu(working)

To install node.js with npm in ubuntu. sudo apt-get install nodejs npm -y The npm is used to install  phonegap and the code : sudo npm install -g phonegap To force the instalation process f is added in above code like : sudo npm install -gf phonegap

Defining php5.5 by rasmus lerdorf

PHP5.5 perforance Inmprovement: nested calls call stack pre-allocated by compiler bundled opcode cache Generators: <?php function xrange($start,$end) {     for ($i=$start;$i <= $send;$i++) {         yield $i;     } foreach (xrange(0,5) as $i) {      echo $i,"\n"; } finally: <?php $db=mysqli_connect(); try{ call_some_function($db); }finally{ mysqli_close($db); } list() in foreach $names =[["john","smith"],["fred","johnson"]]; foreach($names as list($first,$last)){ echo $first,$last; } Const array/string Dereferncing: echo array(1,2,3)[0];//output 1 echo "foobar"[3];//output b echo[1,3,4][2];//output 4 empty() support for functions/expressions curl upload functionality rewritten simplified password hashing API

correction in joomla3.2

Yesterday, I tried to install joomla3.2 package in ubuntu12.04LTS and it successfully installed but the problem I faced is after removing installation files.There showed error as no configuration file.It seems like joomla3.2 removes configuration and database file from package.alternative i tested the joomla2.5   is installed and worked fine. Solution: before installing joomla3.2 copy the configuration and database file from joomla3.2 and install it.If the error raises of missing configuration file just add both file in the package and configure manually.