Function trim (myString) { return myString.replace(/^s+/g,'').replace(/s+$/g,'') }
Tuesday, October 30, 2012
Javascript trim function
Monday, October 29, 2012
Textbox accept digits
script language="javascript" type="text/javascript">
function CheckNumeric(e) {
if (window.event) // IE
{
if ((e.keyCode < 48 || e.keyCode > 57) & e.keyCode != 8) {
event.returnValue = false;
return false;
}
}
else { // Fire Fox
if ((e.which < 48 || e.which > 57) & e.which != 8) {
e.preventDefault();
return false;
}
}
}
</script>
<input type="text" onKeyPress="CheckNumeric(event)" />
function CheckNumeric(e) {
if (window.event) // IE
{
if ((e.keyCode < 48 || e.keyCode > 57) & e.keyCode != 8) {
event.returnValue = false;
return false;
}
}
else { // Fire Fox
if ((e.which < 48 || e.which > 57) & e.which != 8) {
e.preventDefault();
return false;
}
}
}
function IsNumeric(sText) { var ValidChars = "0123456789."; //loop through the string passed in, iif its in the validchars list, continue, otherwise, return false for(i = 0; i < sText.length; i++) { if(ValidChars.indexOf(sText.charAt(i)) == -1) { return false; } } return true; }
function validateNumerical(evt) { var theEvent = evt || window.event; var key = theEvent.keyCode || theEvent.which; key = String.fromCharCode( key ); var regex = /[0-9,\.]/; if( !regex.test(key) ) { theEvent.returnValue = false; if(theEvent.preventDefault) { theEvent.preventDefault(); } } }
</script>
<input type="text" onKeyPress="CheckNumeric(event)" />
Friday, October 26, 2012
Thursday, October 25, 2012
Sunday, October 21, 2012
copy row from another table
INSERT INTO Table (foo, bar, Event_ID)
SELECT foo, bar, Event_ID+"155"
FROM Table
WHERE Event_ID = "120"
Friday, October 19, 2012
MySQL Joins
http://www.sitepoint.com/understanding-sql-joins-mysql-database/
Tuesday, October 16, 2012
Print only a part of the page
<div id="printableArea">
<h1>Print me</h1>
</div>
<input type="button" onclick="printDiv('printableArea')" value="print a div!" />
function printDiv(divName) {
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
}
==========================================================================
using frames
==========================================================================
<html> <head> <title>Print Test Page</title> <script> printDivCSS = new String ('<link href="myprintstyle.css" rel="stylesheet" type="text/css">') function printDiv(divId) { window.frames["print_frame"].document.body.innerHTML=printDivCSS + document.getElementById(divId).innerHTML; window.frames["print_frame"].window.focus(); window.frames["print_frame"].window.print(); } </script> </head> <body> <h1><b><center>This is a test page for printing</center></b><hr color=#00cc00 width=95%></h1> <b>Div 1:</b> <a href="javascript:printDiv('div1')">Print</a><br> <div id="div1">This is the div1's print output</div> <br><br> <b>Div 2:</b> <a href="javascript:printDiv('div2')">Print</a><br> <div id="div2">This is the div2's print output</div> <br><br> <b>Div 3:</b> <a href="javascript:printDiv('div3')">Print</a><br> <div id="div3">This is the div3's print output</div> <iframe name="print_frame" width="0" height="0" frameborder="0" src="about:blank"></iframe> </body> </html>
Subscribe to:
Posts (Atom)