Friday, 16 December 2011

Finding Position of an HTML element in JavaScript.

<script language="JavaScript">
function find_pos(event){
    pos_x = event.offsetX?(event.offsetX):event.pageX-document.getElementById("pointer_div").offsetLeft;
    pos_y = event.offsetY?(event.offsetY):event.pageY-document.getElementById("pointer_div").offsetTop;


Use in HTML Page.



Thursday, 15 December 2011

MYSQL User format ID Generation

Generate defined/User defined format Serial No from Database .There may be some condition where
I found this type of query which will help you to find the user format no from database.No. like
001 to 999 .

The Query for MySQL:

select case  when (intfield_id<=9 ) then concat('00',cast(intfield_id as CHAR))
when (intfield_id<=99 and intfield_id>9) then concat('0',cast(intfield_id as char)) when
(intfield_id<=999 and intfield_id>9 and intfield_id>99) then concat('0',cast(intfield_id as char))
end columnname from test