It is Bip Bip Bipool

November 14, 2008

Delete all rows from table in javascript

Filed under: Uncategorized — bipool @ 21:17

for(var i = document.getElementById(“tableId”).rows.length; i > 0;i–)
{
document.getElementById(“tableId”).deleteRow(i -1);
}

If you do this it generates an error :

for(var i = 0; i <document.getElementById(“tableId”).rows.length; i++)
{
document.getElementById(“tableId”).deleteRow(i -1);
}

The code above wont delete all the rows because “i” is not set back to 0 although the table rows’ index will be set again beginning from zero after any row is deleted from the table.

May 23, 2008

String Concate In JavaScript

Filed under: javascript — bipool @ 18:30

In JavaScript , String concatenation is too much slow. If you have some long string and need to concate in a loop.  It will take long  time to execute the process. If your loop iteration is like 2000 times and your string like 100 characters long, then it might take 7-8 seconds to execute. Thats a real fact for optimization. JavaScript actually store data in many places when concate  the string.

If you do following way then process time will reduce significantly. If you store every string in an array and then join the string using array.join(“”) function , it will reduce time. I got it reduces 70-75% time of previous one .

February 13, 2008

strpos vs strrpos

Filed under: Php, Programming — bipool @ 16:24

In php, today i found that ‘strpos’  return the first occurrence of the looking string in the full string and ‘strrpos’ should do the last occurrence . But it is not looking last occurrence string , looking last occurrence character. Why this ? :S

December 23, 2007

Java script framework comparison

Filed under: javascript — bipool @ 07:07

‘EXT’ is a very rich javascript framework. There is lots of components
like Grid, Tree, Tab, dialogbox, Debug consol, toolbar, menu etc.It is
based on YUI[1], JQuery[2], Prototype[3] & Script.aculo.us[4] framework.
Ext framework is included those frameworks. So, when you will work by this
framework,can get access other framework’s advantages. Ext has also its
own library in ext.js which is added in 2.0 . So here you are getting a
huge library to work.

But the problem is onloading time, it will take loooong time to load a
page.On the other hand, if you use Mootools[5], it is super lightweight.
A lot of components also in here but not like EXT. It is tremendous
fast. The mechanism of Moo is, there has individual package for each
components. There is no too much dependency to another packages. So you
can include those packages in a page what you needed, no need to load
another.

JQuery also a very good framework.It is easiest one and it has very good
documentations.The main difference between JQuery and mootools/prototype
is DOM travers . JQuery make it very simple , just give the id of an
element and get the object. On the otherhand Moo do it by making
classes. JQuery also work fine on AJAX. JQuery is simple and easy to
remember. I think, JQuery and Moo both are good. JQuery is good for
simple small projects and Moo is for complicated projects where object
oriented programming really helps.

Thanks

[1] http://developer.yahoo.com/yui/
[2] http://jquery.com/
[3] http://www.prototypejs.org/
[4] http://script.aculo.us/
[5] http://mootools.net/

October 23, 2007

Ajax Limitation

Filed under: ajax — bipool @ 22:23

Today I faced a problem, when i was using AJAX for saving data from a page. But I was getting always script error. But I could not find out , what was the problem . After sometimes, I got the problem. The problem was ajax can not submit more than 2KB data.

Then I break out the data and send those data by using multiple ajaxing. And then that was working fine :)

October 22, 2007

PHP : usort function

Filed under: Uncategorized — bipool @ 16:57

Before somedays , I was working on sorting issue. I was using usort function. In this function, you can define sort criteria. Here you can send 2 variable as parameter , then write ascending or descending or any criteria .

I was using this and I had multi-dimensional array . Thats why, I was writing in the body part of the usort like following
$a[0] > $b[0]

And this way, It is working fine.

But When I using a variable instead of hard code ’0′ like following

$index = 0;

$a[$index] > $b[$index]

It is not working. It is not accepting variable here.

Then I was trying to use ‘create_function()’ where i was using variable and thats work really fine

Thanks

August 8, 2007

arguments.callee :: javascript

Filed under: javascript, Programming — bipool @ 21:00

If you want to use anonymouse function in javascript then you can easily use arguments.callee

As example :

function makeFactorial(){

return function fact(x)

{

if(x > 1)

return x * argument.callee(x-1)

}

}

makeFactorial()(4) ;

output is 24.

also you can see the arguments by using func_name.arguments

javascript :: function

Filed under: Uncategorized — bipool @ 20:47

There are several ways you can write a function in javaScript.

1. first of all a simple and popular way “Function Statement”.

function  func_name ([param],[param],……[param] ){

// statement

}

2. Second way is “function Operator”

var func_name  = function ([param],[param],……[param] ){

//statement

}

3.  Another way is “function constructor”

var  func_name = new function ([param],[param],……[param] ){

//statement

}

In function operator , you can assign the function to another variable but in function statement You can not do this.

In function operator, you can use array of function . as Example…

var fn = array[  function (x )  {return x;} , function (x )  {return x*x ;},function (x )  {return x*X*x;}

]

for  fn[0](5) , output is 5

for  fn[1](5) , output is 25

for  fn[2](5) , output is 125

July 22, 2007

Google Reader, Thanks!!!!!

Filed under: ETc, Myself — bipool @ 09:32

Now I am using Google Reader to read blog and various news. If that site RSS is enabled then Google reader will feed that news from that site. You have to give just RSS address then Google reader will pull news. I generally read from many sites. Now i don’t need to go to that site everyday. In one place i got the news. It is easy to read and flexible . I can maintain or sort this news easily. Also I can store this news in offline.  :)
Thanks GooGle Reader !!!!

May 1, 2007

Multiple ajax call at a time

Filed under: ajax, javascript — bipool @ 21:14

Before some days, I was facing a problem for multiple request by ajax at a time.Generally , when i request for multiple pages by ajax , if second request is sent before first response is come then first call is no found. For that, I have made a queuing system for multiple call. When a request is made i am storing this information in an array . After getting response, I am just removing those info from the array. Then checking any more info is left in array, If yes then I call again.


arrInfo.push(info);

funciton : AjaxCall()
{
....
....
// take info from array's 1st element
// and call the ajax
}

function : getResponse()
{
...
...
arrInfo.splice(0,1); // removing this info
if(arrInfo.length) AjaxCall();

}

Actually, it will call one by one. But no risk to lost any response.:)

Older Posts »

Theme: Banana Smoothie. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.