Tuesday, 10 January 2017

How to check browser version?

<script>

    function myFunction() { 
     if((navigator.userAgent.indexOf("Opera") || navigator.userAgent.indexOf('OPR')) != -1 ) 
    {
        alert('Opera');
    }
    else if(navigator.userAgent.indexOf("Chrome") != -1 )
    {
        alert('Chrome');
    } else{
 
 }
</script>

<SCRIPT LANGUAGE="JavaScript">
var browsername;
var browserVersion;
function checkBrowser() {
  browsername = navigator.appName;
  // Sets the version number (e.g., 4.03)
  browserVersion = parseFloat(navigator.appVersion);
  if(browsername.indexOf("Netscape")!= -1) {
    browsername="NS";
  } else {
    if(browsername.indexOf("Microsoft")!=-1) {
      browsername="MSIE";
    } else {
      browsername="N/A";
      alert("Unknown browser: " + browsername);
    }
  }
  //-- code goes here........
  alert("Your Browser Name : " + browsername + " Version : " + browserVersion);
}
</SCRIPT>

Call the above functions on the body onload event. 

How to handle multiple submission in web page?

The simplest way to handle the multiple submit problem is to prevent it from happening. Below is a form, which includes a small amount of JavaScript. The embedded JavaScript remembers if the submit button was previously pressed. On a resubmit, an alert pops up and the form is not submitted again.

 <html>
 <input type="button" name="btnSubmit"
 value="Do Submit"
 onClick="checksubmitcount();">
 </td>
 </tr>
 </table>
 </form>

 <script language="javascript">
 var submitcount = 0;
 function checksubmitcount()
 {
  submitcount++;
  if (1 == submitcount )
  {
   document.Order.submit();
  }
  else
  {
   if ( 2 == submitcount)
    alert("You have already submitted  this form");
   else
    alert("You have submitted this form"
    + submitcount.toString()
    + " times already");
  }
 }
 </script>
 </body>
 </html>

Friday, 20 November 2015

How to remove line numbers from the copy pasted code in Notepad++

Hope many of us faced this issue while copy pasting the code. Along with the code, the line numbers will also be pasted. There are many ways to remove this line numbers from the code. In Notepad++, We can use regex ^\d+ in the Find and Replace option. But there is another handy way which is explained below.

Let's say we have a html code as below: 

1: <html>
2: <body>
3: <h1> HELLO PROGRAMMER </h1>
4: </body>
5: </html>

If We wish to remove the line numbers from 1 to 5, there is a handy way for this. Press the <Alt> key and Drag the mouse on the numbers with the left mouse button pressed. This will select the numbers alone. Thus we can delete the numbers easily with this feature in Notepad++.

Tuesday, 11 February 2014

resultSet.next() always returns “false”!!

You might be executing some query in your application and even though that you verified all the connection parameters like connection URL to the database, username and password, and the SQL statement that you fired, and that data also resides in the database in proper table. Yet resultSet.next() is always returning false. 

The retrieved resultSet actually points initially to a location before the actual data index, so with first resultSet.next() call, the resultSet pointer now points to the first fetched record in the database. This is ridiculous and had wasted more time. Actually I failed tocommit the data after inserting into the table. Without committing, that data never is written to the database schema. So check, did you really do a 
SQL> commit;
After scorching my head for over hours for these 7 characters of wisdom ( c-o-m-m-i-t-; ), I unleashed the forgotten thing: DML commands need to be committed/rolled-back for changes to take effect.

Thursday, 9 January 2014

Autofill Date in Excel Sheet columns

Hope everyone aware of filling Numeric values and filling Numeric series in Excel sheet(Microsoft). We can achieve filling Numeric values by just dragging the particular cell and filling Numeric Series by dragging the particular cell along pressing 'Ctrl' Key.

Filling Numeric value '1' from cells B2 to B11
Filling Numeric value '1' from cells B2 to B11


Filling Numeric series - '1 to 10' from cells B2 to B11
But what shall we do to fill Date values in excel columns.This can be achieved by dragging the cell by right clicking. You can choose either Day,Week,Month and Year.


Step-1

Step-2