ASP.NET (35) SQL (25) JAVASCRIPT (24) HTML (14) STYLE SHEET (6) ASP (4) SCRIPT (1)

Search me out HERE!!

To Create WORD FILE and write in it in PHP

Below code is to create WORD file and then write in it. Its simple form, and value entered in Textbox will be written in WORD file.

<?
if($_POST)
{   
    $fp = fopen("test.doc", 'w+');
    $str = "First Name: " .$_POST['fname']."\n";
    $str .= "Middle Name: " .$_POST['mname']."\n";
    $str .= "Last Name: " .$_POST['lname']."\n";
    fwrite($fp, $str);
    fclose($fp);
}
?>

<form method="post">
First Name : <input type="text" name="fname"><br />
Middle Name : <input type="text" name="mname"><br />
Last Name : <input type="text" name="lname"><br />
<input type="submit" name="submit">
</form>

Setting TEXTBOX Background Image and Color Using JavaScript & CSS

Consider below textbox:
<input type="text" id="textbox_name" />

Now you can apply BACKGROUND COLOR or BACKGROUND IMAGE using below JAVASCRIPT or CSS
// USING STYLE CSS
.textbox
{
background-color:#FFFFFF;
background:url(images/test.jpg);
}

// USING JAVASCRIPT
function set_background
{
document.getElementById('textbox_name').style.backgroundColor = '#FFFFFF'; document.getElementById('textbox_name').style.backgroundImage="url(images/test.jpg)";
}

TO FIND BROWSER USING JAVASCRIPT

Using below JavaScript you can get information about browser.

<script language="JavaScript" type="text/javascript">
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // For IE
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;  // For Firefox
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;  // For Opera
alert(isIE);
alert(isWin);
alert(isOpera);
</script>

Count Number of letter in Textarea or Textbox using Javascript

Kindly write anything in Textbox:


Characters left

Code:
Javascript Function:
<script language="javascript">
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}
</script>


HTML
<form name="frm">
<textarea name="comments" id="comments" cols="30" rows="4" wrap="physical" onKeyDown="textCounter(document.frm.comments,document.frm.remLen1,100)"onKeyUp="textCounter(document.frm.comments,document.frm.remLen1,100)" tabindex="14"> </textarea>
<br />
<input readonly type="text" name="remLen1" style="border:0; width:30px;" size="3" maxlength="3" value="100"> Characters left
</form>


Calendar using Javascript


DEMO:

Date: 


   (Click in Textbox)

Click on below link to Download .js file
Click Here

Code for HTML Page
<script language="javascript" type="application/javascript" src="scw.js"></script>

Date:<input  type="text" name="test" onselect='scwShow(this,event);' onclick='scwShow(this,event);' readonly="readonly" />

To apply COMMON CSS to all Textbox, Radio Button, Checkbox

Below CSS can be used to apply to all TEXTBOX, RADIO BUTTON or CHECK BOX without giving class.

CODE to be implemented in style.css file:

input[type=text] 
{
//Here will be property as per requirement. 
}

input[type=radio] 
{
//Here will be property as per requirement.
}


input[type=checkbox] 
{
//Here will be property as per requirement. 
}

Same way you can apply CSS to any input type.

How to disable HTML attribute using JAVASCRIPT

Below JavaScript can be used to disable HTML Attributes during run time. (Eg: TextBox, Select Box, Check Box, Radio Button, Etc)

<script>
window.onload= function()
{
          DisableEnableForm(document.frmwitness,true);
 }

function DisableEnableForm(xForm,xHow){
  objElems = xForm.elements;
  for(i=0;i
  {
       var ck = objElems[i].type;
       if(ck=="select-one" || ck=="text")
      {
          objElems[i].disabled = xHow;
       }
   }
}
</script>


Note: You can call above function as per requirement.