08 April 2009

0 To check all checkbox when select-all is checked or to deselect all when select-all is unchecked

Here is the JavaScript code snippet for checking all checkbox when select-all is checked or to deselect all when select-all is unchecked


// to check whether select-all(Select All) check-box is checked or not

// call this function when the select-all(Select All)checkbox is clicked

function checkAll() {

var check = document.getElementsByName("checkAll");

if(check[0].checked==true){

selectAll(check);

}

else {

deSelectAll(check);

}

}

// to select all the check-boxes

function selectAll(check){

var check2 = document.getElementsByName("checkItem");

for (var i=0; i<check2.length; i++) {

check2[i].checked=true;

}

}

// to de-select all the check-boxes

function deSelectAll(check){

var check2 = document.getElementsByName("checkItem");

for (var i=0; i<check2.length; i++) {

check2[i].checked=false;

}

}



- checkAll is the name of the select-all checkbox
- checkItem is the name of the other checkboxes


Read More...

16 March 2009

1 Function Overloading or Method Overloading in JavaScript

Function Overloading or Method Overloading in JavaScript

Though JavaScript is an object oriented language, it is not at all supporting function overloading or method overloading. If you had written more than one function with the same function name, the last one will override all the former. That is, you cannot implement function overloading or method overloading in JavaScript. There is an interesting factor regarding this. Let us consider a situation

You had defined a function with one input parameter, but in the function call you are not passing anything, just calling that function. Even now it will not throw any JavaScript error message; it will simply execute that function.

No matter whether your function definition is with or without input parameter, the function will be simply executed without throwing any JavaScript error. Number of input parameter is immaterial in case of the JavaScript function calls, only function name or the method name matters.

Let’s take a look, what will happen if you try for function overloading in JavaScript.

You are defining a function, say funKnight with no input parameter, and then you are defining the same function with different numbers of input parameters and keeping different alert messages for each definition. Then just try to call this function from anywhere of your page, you can see that irrespective of the number of input parameters (zero or more than zero) you passed while calling the function, the last defined one will be executed. And you will be getting the last definition’s alert message. You can try with the code which I had given below. 

<html>

<head>

<script language="JavaScript">

function funKnight(first)

{

        alert("FunKnightfirst");

}

function funKnight(first,second)

{

alert("FunKnightfirst,Second");

}

function funKnight(first2)

{

        alert("FunKnightfirst2");

}

function funKnight()

{

        alert("Simple-FunKnight");

}

</script>

</head>

<body>

<input type="Button" name="inputButton" value="Click here" onClick="funKnight()">

</body>

</html>

I had tried this code (method overloading or function overloading) with all the leading browsers such as Internet explorer 7.0 and lower versions, Mozilla Firefox 3.0.7 and lower versions, Google chrome and Opera; I could not implement function overloading anywhere. The last definition did simply override every other. Let’s conclude, till the date Browsers are not supporting function overloading (Method overloading) for JavaScript

Read More...

11 March 2009

0 Thick client and Thin client programs difference

As a developer you may have a question about the advantages and disadvantages of thin client as well as thick client programs. If you are an online application developer somewhere you would have been feel the following questions in you mind at least once.

What are the advantages/disadvantages of developing solution as thick client?

What are the advantages/disadvantages of developing solution as thin client?

Here you go……


Desktop application (Thick client applications)

Advantages of thick client applications

1) Performance - Application Response to user's request will be faster

2) Cost development/deployment is less

3) Extremely rich GUI is possible

4) Offline working possible (with low cost)

5) Accessing local resources/hardware is simple/easy

 

Disadvantages of thick client applications

1) High Operation or Maintenance Cost - Each release may need a reinstallation or patch upgrade to all the clients. 

2) Overall more computing resources required (when the resources of all the client machines put together)

3) More Energy cost - overall more energy utilized

4) Less secured as the program is distributed to all the clients

5) Depending upon the increase in application resource utilization for each release/version, there might be a need to upgrade all the client hardware.

6) Each OS might need a different build (even in some cases of swing application)

 

Web based application (Thin Client applications)

Now a days with RIAs most of the desktop applications can be developed in web based application (while cost of development being higher).

 

Advantages of thin client applications

1) Low Operating/Maintenance cost

2) Overall low computing resources required

3) Less Energy Cost - Overall less energy is utilized

4) More secured

5)  More Portable - deploy once run anywhere

6) In case of RIA - can have almost all of the features in desktop application

 

Disadvantages of thin client applications

1) Cost development/deployment is high

2) Difficult to develop extremely rich UI

3) Offline working is costly or impossible

4) There might be a performance issue - in case of more network intensive calls to server.

Read More...

24 February 2009

0 Disabling rightclick in your website is not worthy

Disabling rightclick is not a good idea? why?

(Learn How to disable Right click in you Website or Blog, Here)

After working long time on a design or a code or an article you may want to protect it, you may be thinking of protecting your asset by using a JavaScript that disables rightclick.

It may looks fine; however this isn't a good idea. Why not? The following are the reasons.


Disabling right click is irritating

You may not be realizing that how much you use right-click until you can't use it! There are a lot of other useful and efficient features are there in the right click. While most are also available in the menu bar of the browser window, it's often much quicker to use the right-click menu, as rightclick menu is usually the closest menu you have available, in your reach.


Disabling right click is worthless

Do you think disabling right-click will protect your source code or images? If someone is determined to steel your code they will do it regardless of whether he is able or not to access browser context menu. If they need your source code then there are too many ways to get your source code. Keep one thing in mind; whenever you are viewing a page from the internet, it’s a download. That is, the page is downloading from the server with all its content, which will be residing at your temporary folders. If someone is so determined to retrieve something from your webpage he can simply do that. There is an add-on for Mozilla Firefox, Firebug. Actually its developer tool, to debug or develop JavaScript, CSS codes, But with this Firebug you can download each single element from a webpage to you system. All that need is just open the page in Firefox, download and install firebug. I had downloaded .SWF files even the protected streaming videos using the firebug.

Disabling right-click will only make people to think about what you're exactly trying to hide. And this could end up being just opposite effect, as your images and source code attract unwanted attention.


Important: - you can only disable right-click on browsers that have JavaScript enabled: if a user is just disabling the JavaScript in his browser, the whole code will be an utter failure.


Disabling right click is unprofessional and insulting to the normal user

Disabling right click is unprofessional way to protect your asset. Most of your visitors will come to your site looking information or any services. Only a very small number of your visitors will visit your site with the intention to steal something from it. By trying to protect your asset from the crooked minority, you effectively insult the normal users, who will use the right-click menu for reasonable reasons. Do you really want to lose some of your repeated visitors by just trying to protect your contents?

Agreed, some crooked minded people may want to use your source code, but don't assume that everyone who looks at it will want to reuse it.

Read More...

19 February 2009

1 Running an SAS program in 9S region

We had a problem in running a SAS program in 9S region.

If anyone has executed a SAS program in 9S with connection to Teradata it will be helpful.

The description of the problem is as follows:


  1. We have a sample SAS program which is running fine in 1D.
  2. But when we tried replicating the same program in 9S it’s not able to connect to Teradata.
  3. We have imported CONNECT and other macros to 9S region. We even changed the CONNECT macro to point to the load id location in 9S.
  4. We have also changed the SASAUTO location in the JCL to point to the corresponding location in 9S
  5. The error displayed is: “Teradata Connection Error”
  6. Apart from Connect to Teradata I have given PROC PRINT statement which is working fine in 9S. Only problem is while connecting to Teradata I am getting the error.

We got a solution for the above problem, It goes like this, Just sharing with everybody on the same.

 

In order to connect to Teradata from the 9S, your job must run specifically on the 9S04.  Even if you log on to the 9S04, your job might run on another partition (eg. 9S01, 9S02, etc) unless you add the following after your jobcard:

//*+JBS BIND SYS9S04.PERM

This will “bind” your job to the 9S04.

For example, here is the JCL I use:

//T48983J JOB 00412,'SAS TEST',MSGLEVEL=(1,1),

//  CLASS=0,MSGCLASS=V,NOTIFY=T48983

//*+JBS BIND SYS9S04.PERM

//SAS EXEC SASMSTR,LOAD='SYS3A.TERADATA.APPLOAD',

//         SASAUTO=SAS.MACLIB'

//SYSIN DD *

Read More...