Home and Blog button

Pages

Introduction

Welcome To my Blog !!
This is a blog where you can get some knowledge that i have learned and been using. Sharing is gaining pals. So Happy Sharing and don't forget to follow and link my blog with yours! Thanks.
Happy Programming!!

Tuesday, September 22, 2009

Use Of Bgcolor To new Window Using JavaScript!!



Use of bgcolor to new window !!



Choose the bgcolor:





<html>
<head>
<title>Colors!!</title>
<script language=javascript>
function NewWindow() {
new_win = window.open("","defaultwindow","toolbar=yes,resizable=yes");
cindex=document.form1.cbocolor.selectedIndex;
color = document.form1.cbocolor.options(cindex).text;
new_win.document.write("<html><body bgcolor="+color+">Color changed successfully!!</body></html>");
}
</script>
</head>
<body>
<center>
<strong>Use of bgcolor to new window !!</strong>
<hr>
<form name=form1>
Choose the bgcolor: &nbsp;
<select name=cbocolor>
<option name=blue>Blue </option>
<option name=green>Green</option>
<option name=pink>Pink</option>
<option name=black>Black</option>
<option>Yellow</option>
</select> <br>
<br>
<input type=button name=cmdok value=" OK " onClick="NewWindow()">
</form>
</center>
</body>
</html>

Simple Calculator Using JavaScript

This is a simple calculator program written in JavaScript:

Simple Calculator



Exit Calculator!!

<title>Simple Calculator!!</title>


2009 © to Rajan

<script language=javascript>
var Novalue = 0;
function disp(element) {
if (Novalue == 1) {
document.form1.txtres.value = "";
Novalue = 0;
}
document.form1.txtres.value=document.form1.txtres.value+element.value;
}

function calc() {
document.form1.txtres.value = eval(document.form1.txtres.value);
Novalue = 1;
}

function clearall() {
document.form1.txtres.value = "";
}
</script>
</head>
<body>
<center>
<a href="" onMouseOver="if(confirm('Are you sure you want to exit!!')) { exit();};return true;">Exit Calculator!!</a>
<form name="form1">
<table width="204" height="168" border="1" cellpadding="3" cellspacing="3">
<tr>
<td colspan="6"><center><input type="text" name="txtres" readonly="no" width="190"></center></td>
</tr>
<tr>
<td width="28" height="29"><input type=button value=1 name=cmd1 onclick=disp(this.form.cmd1)></td>
<td width="28"><input type=button name=cmd2 value=2 onClick=disp(this.form.cmd2)></td>
<td width="28"><input type="button" name="cmd3" value="3" onClick="disp(this.form.cmd3)"></td>
<td width="25"><input type=button value=* name=cmdmul onclick=disp(this.form.cmdmul)></td>
<td width="37" colspan="2"><input type=button value=+ name=cmdplus onClick=disp(this.form.cmdplus)></td>
</tr>
<tr>
<td><input type="button" name="cmd4" value="4" onClick="disp(this.form.cmd4)"></td>
<td><input type="button" name="cmd5" value="5" onClick="disp(this.form.cmd5)"></td>
<td><input type="button" name="cmd6" value="6" onClick="disp(this.form.cmd6)"></td>
<td><input type=button value=/ name=cmddiv onclick=disp(this.form.cmddiv)></td>
<td width="37" colspan="2"><input type=button value=- name=cmdminus onclick=disp(this.form.cmdminus)></td>
</tr>
<tr>
<td><input type="button" name="cmd7" value="7" onClick="disp(this.form.cmd7)"></td>
<td><input type="button" name="cmd8" value="8" onClick="disp(this.form.cmd8)"></td>
<td><input type="button" name="cmd9" value="9" onClick="disp(this.form.cmd9)"></td>
<td><input type="button" name="eq" value="=" onClick="calc()"></td>
<td width="37" colspan="2"><input type=button value=Clr name=cmdclear onClick=clearall()></td>
</tr>
<tr>
<td colspan="6"><center><font face="Courier New, Courier, monospace" size="-1"> 2009 &copy; to Rajan</font></center></td>
</tr>
</table>
<br>
</form>
</center>
</body>
</html>

Friday, September 4, 2009

Java Script: Introduction

JAVASCRIPT IN WEBPAGES


Today's web sites need to go much beyound HTML. There is definite need to allow users, browsing through a web site, to actually interact with the web site. The web site must be intelligent enough to accept users input and dynamically structure web page content, tailor made to the user's requirements.
Capturing usr requests is traditionally done via a FORM. Hence the web site development environment needs to have the facilities to create forms. After a form captures user input, the form must have a built in technique for sending the information captured back to the web server for processing. Processing user requests is generally done via scripts(small programs) that are based on the server.
The web site development environment should also provide facility for Validating user input. Invalid user input, will either cause data to be sent back from the web server to the browser from the web server. Neither of which would really attract repeat visits to the web site.
Hence, the web site development environmnet must also facilitate coding which runs in a browser at client side for data validation. Most development environments offer statnd constructs for data validation. Standard programming constructs are:
  • Condition checking constructs
  • Case checking constructs
  • Super controlled Loop constructs
JAVASCRIPT
Javascript is a scripting language (web site development environment) created by Netscape hence Javascript works best with the Netscape suite of Client and Server Products. It is also the default scripting language that Netscapte understands.
Client side javascript is traditionally embedded into standard HTML program. Javascript is embedded between the <script>...</script>
HTML tags. These tags are embedded within the <head>...</head> or <body>...</body> tags fo the HTML program.
Only a browser that is JavaScript enabled will be able to interpret JavaScript code.
Javascript is an object-oriented language that allows creation of Interactive Web Pages. JavaScript allows user entries, which are loaded into an HTML form to be processed as required. This empowers a web site to return site information according to a user's requests.
Advantages Of JavaScript
  1. JavaScript is an interpreted language, which requires no compilation steps. This provides an easy development process.
  2. JavaScript is embedded within HTML which does not require any special or separate editor for programs to be written, edited or compiled.
  3. Minimal syntax - Easy to learn
  4. Quick development due to no need for compilation.
  5. Designed for programming user events such as button, mouseover, oncilck etc.
  6. Easy Debugging and Testing
  7. Platform Independence / Architectural Neutral since it works with any machine which is javascript enabled.
Syntax:
<SCRIPT LANGUAGE="Javascript">
// Javascript code snippet written here
<SCRIPT>

Search This Blog