Monday, 20 February 2012

Adding inner table to a dynamic td of a table

Try This codes


Script

<script language="javascript">

function addtabletesting(tableID) {


var table1 = document.getElementById(tableID);      
var rowCount1 = table1.rows.length;      
var row1 = table1.insertRow(rowCount1-1);
var td1 = document.createElement("TD");

/*
 creating a new row row1 andadded a column td1
*/

var table2= document.createElement("TABLE");
var rowCount2 = table2.rows.length;      
var row2 = table2.insertRow(rowCount2);
var td2 = document.createElement("TD");

/*
Created a new table table2 added row2 and td2.
*/
td2.innerHTML = "<h4>my new column in new inner table </h4>";

row1.appendChild(td1);
td1.appendChild(table2);
row2.appendChild(td2);
/*
Added td1 into row1, table2 into td1, and td2  into row2.
*/

}

</script>

html


<table id="testtable1" border="1">
<tr><td width="150">old table row 1 column 1</td></tr>
<tr><td>old table row 2 column 2</td></tr>

<tr><td> <a  onclick="addtabletesting('testtable1')" >Add table</a> </td></tr>
</table>

Auto adjusting height and width of window to screen size


Add th following code


<script  type="text/javascript">
function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  window.alert( 'Width = ' + myWidth );
  window.alert( 'Height = ' + myHeight );
}
</script>

Calling a popup

For adding a popup in an anchor tag use the following code ( Tiles)

<a  NAME="Search Criteria Window" title=" Search Criteria " onclick=window.open('mypage.action',"Ratting",'width=800,height=250,left=150,top=200,toolbar=0,status=0,addressbar=0,');> my page </a>

For normal pages insted of mypage use mypage.jsp


For calling a full screen popup


onclick="theURL='#'; window.open(theURL, '', 'fullscreen=yes, scrollbars=yes' );"

Controlling parent window from popup window


Use the following function

<script langauge="javascript">

function post_value(){

self.close(); //Closing popup window

//Redirecting parent to normal jsp page
window.opener.location.href=" pagename .jsp?item1="+document.frm.textfieldtest.value;

//redirecting parent when tiles is used
window.opener.location.href="pagename";

// assigning a value toa field in parent
opener.document.form1.par_name1.value = document.form2.textfieldtest.value;

}
</script>

Thursday, 9 February 2012

Rotate a text



-webkit-transform: rotate(-90deg); /* Safari */
-moz-transform: rotate(-90deg); /* Firefox */
-ms-transform: rotate(-90deg); /* IE */
-o-transform: rotate(-90deg); /* Opera */
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); /* Internet Explorer */

or


  -webkit-transform: rotate(7.5deg);  /* Saf3.1+, Chrome */
     -moz-transform: rotate(7.5deg);  /* FF3.5+ */
      -ms-transform: rotate(7.5deg);  /* IE9 */
       -o-transform: rotate(7.5deg);  /* Opera 10.5 */
          transform: rotate(7.5deg);
             filter: progid:DXImageTransform.Microsoft.Matrix(/* IE6–IE9 */
                     M11=0.9914448613738104, M12=-0.13052619222005157,M21=0.13052619222005157, M22=0.9914448613738104, sizingMethod='auto expand');
               zoom: 1;

Wednesday, 8 February 2012

Prompts

Put it in a JS function
prompt("Please enter your name","Harry Potter");

Conformation window

Put these lines inside a java script function

var msg;
msg= "Are you sure you want to delete the data ? " + ttt + " - ID= "+id;
var agree=confirm(msg);