Thursday 23 August 2012

Copy Table Row Using DOM Object

// Call this function onClick event in javascript for copying TR
function addRow(tableID)
{
    dml=document.forms['add_products'];// Form Name
               
    // get the number of elements from the document
    len = dml.elements.length;
     for( i=0 ; i<len ; i++)
     {
        //check the textbox with the elements name
            if (dml.elements[i].name=='rest_prod_price[]')
            {
              // if exists do the validation and set the focus to the textbox
                if (dml.elements[i].value=="")
                {
                    alert("Invalid empty data");
                    dml.elements[i].focus();
                    return false;           
                }
            }
     }
   
     var table = document.getElementById(tableID);
    var rowCount = table.rows.length;
    var row = table.insertRow(rowCount);
    var colCount = table.rows[0].cells.length;
   
    for(var i=0; i<colCount; i++)
    {
        var newcell = row.insertCell(i);
        newcell.innerHTML = table.rows[0].cells[i].innerHTML;
    }
}

 // Call this function onClick event in javascript for delete TR
function deleteRow(tableID)
{   
     var table = document.getElementById(tableID);
    var rowCount = table.rows.length;
    if(rowCount > 1)
    {table.deleteRow(rowCount - 1);}
    else
    {alert('No More Control To Delete.');}
   
}

Wednesday 15 August 2012

Secure Login with Ajax and Jquery

NOTE:-testLogin.php page is where you write login code 
 
function CheckLogin(){
var LoginObj = new Object();
LoginObj.UserName = $("#txtUserName").val();
LoginObj.Password = $("#txtPassword").val();
//Define DTO i.e. Data Transfer Object as follows
var DTO = { 'userLogin': LoginObj };
$.ajax({
type: "POST",
url: "testLogin.php/CheckLogin",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify(DTO),
success: function(msg) {
if (msg.d)
$(".alertmsg").html("Valid Login");
else
$(".alertmsg").html("Invalid Login");
},
error: function(xhr, status, error) {
alert("An error has occurred during
processing: " + error);
}
});
}

Wednesday 8 August 2012

Html div over Flash or Content over a embed object

 
<object id="player" classid="3540000" name="player" width="300" height="200">
              <param name="movie" value="player-viral.swf" />
              <param name="wmode" value="transparent" />
              <param name="allowfullscreen" value="true" />
              <param name="allowscriptaccess" value="always" />
              <param name="flashvars" value="URL" />
              <embed type="application/x-shockwave-flash"
                id="player2"
              name="player2"
               src="player-viral.swf"
             width="300"
            height="200"
                    wmode="transparent"
 allowscriptaccess="always"
   allowfullscreen="true"
   flashvars="file=URL"
       />
</object>

Tuesday 7 August 2012

PHP History & Information

With an increasing community; PHP is considered today as one of the most famous scripting languages. It is widely used today as a general purpose scripting language, particularly useful for web developments and like other scripting languages; it can also be embedded directly into the HTML code. Within a short span of time, PHP has gained remarkable popularity and its community is increasing rapidly. There are various reasons for that, for instance:
  • PHP, as you may know, is a free software and anyone can download it; use it and it supports various operating systems
  • The syntax of PHP is quite similar to C which makes it more appealing for computer programmers.
  • Whatever you have done with Perl in the past, you can do it with PHP.
  • PHP is web specific and is more powerful than Perl.
  • PHP works equally well and can be deployed on many web servers like Apache, IIS etc
  • PHP scripts can be used for various standard network protocols as well.
PHP, as mentioned earlier, stands for PHP Hypertext Processor. It is an open source software so you can easily download it from its site; www.php.net. PHP is a mixture of various languages like Java, C and Perl. It was designed with the intention of producing dynamic and interactive web pages. It is capable of producing standalone graphical web applications. Another important fact about PHP is that it can be used as a procedural language in order to create complex objects.
PHP was originally a personal project called as Personal Home Page Tools developed by Rasmus Lerdorf in the year 1994. That was the original version of PHP which consisted of some basic web tools, a parser and some macros. After a while, in the year 1997, the parser was again rewritten and this parser became the basis of PHP3 that gained remarkable popularity. After that, PHP continued to grow and version 4 included a new parser with added features. Today, all the PHP implementations are produced by the PHP group.
Now, as you have learnt some basics of PHP, we shall try building a simple PHP application that will demonstrate you and will help you in learning PHP. Carefully go through the following steps:
  • First of all, you must be aware of the fact that you should have some knowledge of HTML because PHP code is directly embedded into HTML code.
  • Remember that all PHP files have an extension of .phtml or .php.
  • If you haven’t downloaded PHP engine and the Web server then download it immediately before you can use your code. For downloading PHP, visit www.php.net/downloads.php and for downloading Apache server, visit http://httpd.apache.org/download.cgi. Carefully follow the instructions given in the manual in order to install PHP and the Web Server.
  • After you have successfully downloaded PHP and the Web Server, you are ready to create your first PHP web page.
  • Open a notepad file and start writing PHP code.
  • PHP syntax is very simple; every scripting block of PHP starts with <?php and ends with ?>. You can place this scripting block anywhere in the document.
  • Enter the following code of the most famous Hello World example in order to learn the basic syntax of PHP
<html>
<body>
<?php
echo “Hello World”;
?>
</body>
</html>
Echo is used to write output to the browser screen. The most important point here to remember is that, like C, every line of code in PHP ends up with a semi colon. Echo can be replaced with print to get the same functionality. If anyone of you has ever worked on C programming language, you would have noticed the similarity between C and PHP. Save the above file with .php extension and open it, you should be able to see Hello World on the browser screen.