Anyone can comment, so leave your views

Saturday, August 30, 2008

html javascript A demo showing html UI reacting in real time

A demo showing html UI reacting in real time.

Number 1
Number 2
Operation
Result
.
The html:
<html>
<title>A demo showing html UI reacting in real time.</title>
<body>
<form name=f1 action=aa type=get>
<table >
<tr><td>
Number 1</td> <td><input id=t1 onChange=t1c()></td>
 
</tr>
 

<tr><td>
Number 2</td> <td><input id=t2 onChange=t1c()></td>
 
</tr>
 

<tr id=oprw><td>
Operation</td> <td><select id=op onChange=t1c()>
<option value=a>+<option>
<option value=s>-<option>
<option value=m>*<option>
<option value=d>/<option>
</select></td>
 
</tr>
 
<tr><td>
Result</td> <td><input id=r disabled=true></td>
 
</tr>
<tr>
 
<td><input id=d1 onChange=d1c()></td>
</table>
</form>.
<script>
 
function t1c(){
 //alert("t1c");
 var op = document.getElementById("op");
 var t1 = document.getElementById("t1");
 var t2 = document.getElementById("t2");
 var oprw = document.getElementById("oprw");
 if(isNaN(t2.value))return;
 var r =  document.getElementById("r");
 alert("t1c " + t1.value + " t2 " + t2.value + " op " + op.value
 + " Number( t1.value) "+ Number( t1.value)
 + " Number( t2.value) "+ Number( t2.value));
 r.disabled = false;
 switch (op.value){
  case 'a':
  alert ("add" + (Number( t1.value) + Number( t2.value)))
   //r.value = Math.parseDouble(t1.value) + Math.parseDouble(t2.value);
   r.value = String (Number( t1.value) + Number( t2.value));
   break;
  case 's':
   //r.value = Math.parseDouble(t1.value) + Math.parseDouble(t2.value);
   r.value = (1 * t1.value) - (1 * t2.value);
   break;
  case 'm':
   //r.value = Math.parseDouble(t1.value) + Math.parseDouble(t2.value);
   r.value = (1 * t1.value) * (1 * t2.value);
   break;
 
  case 'd':
   //r.value = Math.parseDouble(t1.value) + Math.parseDouble(t2.value);
   r.value = (1 * t1.value) / (1 * t2.value);
   break;
 
 }
 r.disabled = true ;
}
</script>
 
 
</body>
</html>
 
Same but not escaped:
Number 1
Number 2
Operation
Result
. ;

Regards
Tushar Kapila
http://sel2in.com
Java, PHP, VB6 Apps. Fight Back pain: Exercise timer application
http://ksoft7.tripod.com/g3.html search page that allows you to search within any website uses google works best in Internet explorer and opera
http://minutes-alarm.sourceforge.net freeware minute alarm, easy reminder for back ache - stand up or meeting ...


Volunteer computer Cancer cures www.worldcommunitygrid.org
Click: www.thehungersite.com , and www.bhookh.com feed hungry , its free. www.ecologyfund.com
Physics-particle research & you helping http://stephenbrooks.org/muon1
Please add these to your start-up how to: http://tusharkapila.blogspot.com/2008/05/s.html

No comments:

G
 
Forum
Ads by google:











Source code, testing article - one stop shop Software applications written in Java for cell phones, PHP, Java Dot net, PHP & Perl for the web and Vb6, Java, VB6, Perl and Excel VBA for the desktop .

- Tushar G Kapila
Bangalore India 2007 © Remaining page can be removed if you save on your pc or server.

Contributors