Monday, 12 November 2007

HTML: Auto Adjust IFRAMEs

Auto Adjust IFRAME
------------------
<iframe name="ifr" id="ifr" src="whatever.html" onload="this.style.height 
= ifr.document.body.scrollHeight + 5"></iframe> 

OR

<iframe id="ifr" src="ifr.html">< /iframe>< br />
<input type="button" onclick="document.getElementById('ifr').style.height 
= ifr.document.body.scrollHeight + 5" value="Ajust" />

Sunday, 30 September 2007

TSQL: Delete duplicate rows which have the same primary key

--Delete Duplicate Rows
set rowcount 1
delete from hrerequestforapproval
where hrerequestforapprovalid=40508508

TSQL: Get Duplicate Rows Count

--Get Duplicate Row Counts
SELECT hrerequestforapprovalid, count(*)
FROM hrerequestforapproval
GROUP BY hrerequestforapprovalid
HAVING count(*) > 1

Friday, 24 August 2007

HTML: Mailto with CC, Subject, Body prepopulated

<a href="mailto:your.nominateduser@yahoo.com.au?cc=your.nominateduser@yahoo.com.au&subject=A new request&body=Please kindly complete the details below:%0D%0A%0D%0AName:%0D%0ATitle:%0D%0ALocation:%0D%0APhone:%0D%0AMobile:%0D%0A">Click here to email</a>

Wednesday, 15 August 2007

Javascript: Replacing OnLoad attribute in Body tag

//This section runs the SetPage function when the form loads - replaces OnLoad function in body tag
addLoadEvent(SetPage);
function addLoadEvent(func) {   
   var oldonload = window.onload;   
   if (typeof window.onload != 'function') {   
     window.onload = func;   
   } else {   
     window.onload = function() {   
       oldonload();   
       func();   
     }   
  }   
}

//Another example will run when page load but code doesn't utilize onLoad attribute in body tag
var frm = document.frmCreateModifyPosition;
window.onload = function(){
if (frm.txtAction[1].checked){
ShowPositionID()
}
}

Wednesday, 21 March 2007

TSQL: ALTER TABLE

--Alter table
ALTER TABLE MyTable ALTER COLUMN NullCOl NVARCHAR(20) NOT NULL
ALTER TABLE doc_exa ADD column_b VARCHAR(20) NULL
ALTER TABLE doc_exb DROP COLUMN column_b
ALTER TABLE doc_exc ADD column_b VARCHAR(20) NULL CONSTRAINT exb_unique UNIQUE
ALTER TABLE doc_exd WITH NOCHECK ADD CONSTRAINT exd_check CHECK (column_a > 1)

Friday, 9 March 2007

TSQL: UPDATE from values across server via Linked Server

You'll need to setup a linked server first in Enterprise Manager. This is found under Security > Linked Servers. Right click and select "New Linked Server", follow prompts to complete.


Update Dest
SET helpdefinitiontext = T.helpdefinitiontext
From
[erokwis99\dev].mis.dbo.measure as Dest Join
mis.dbo.measure as T On
Dest.measureid = T.measureid

Monday, 30 October 2006

CSS: Display property










































































ValueDescription
noneThe element will not be displayed
blockThe element will be displayed as a block-level element, with a line break before and after the element
inlineDefault. The element will be displayed as an inline element, with no line break before or after the element
list-itemThe element will be displayed as a list
run-inThe element will be displayed as block-level or inline element depending on context
compactThe element will be displayed as block-level or inline element depending on context
marker 
tableThe element will be displayed as a block table (like <table>), with a line break before and after the table
inline-tableThe element will be displayed as an inline table (like <table>), with no line break before or after the table
table-row-groupThe element will be displayed as a group of one or more rows (like <tbody>)
table-header-groupThe element will be displayed as a group of one or more rows (like <thead>)
table-footer-groupThe element will be displayed as a group of one or more rows (like <tfoot>)
table-rowThe element will be displayed as a table row (like <tr>)
table-column-groupThe element will be displayed as a group of one or more columns (like <colgroup>)
table-columnThe element will be displayed as a column of cells (like <col>)
table-cellThe element will be displayed as a table cell (like <td> and <th>)
table-captionThe element will be displayed as a table caption (like <caption>)

Monday, 11 September 2006

REGEX; pattern matching

regular expression to match a U.S. phone number:
\(?\d{3}\)? ?\d{3}[-.]\d{4}

This regex matches phone numbers like "(314)555-4000". 
Ask yourself if the regex would match "314-555-4000" or "555-4000". 
The answer is no in both cases. Writing this pattern on one line 
conceals both flaws and design decisions. The area code is 
required and the regex fails to account for a separator 
between the area code and prefix.

/  
    \(?     # optional parentheses
      \d{3} # area code required
    \)?     # optional parentheses
    [-\s.]? # separator is either a dash, a space, or a period.
      \d{3} # 3-digit prefix
    [-.]    # another separator
      \d{4} # 4-digit line number
/x


replace all instances of double quotes with 
single - /g option is all instances
replace(/\"/g,'\'')

Friday, 25 August 2006

TSQL: Joins with 3 tables

--T-SQL with 3 tables
--Now we take a table more between A and C (it's simple in T-SQL):

update A
set A.a2 = c.c2
from A
inner join B on A.a1 = B.b1
inner join C on B.b2 = c.c1