Text to Speech Using JavaScript
Check this sample code to convert Text to Speech Using JavaScript………..It works only in IE Becoz ActiveX is supported only in Internet Explorer.
<html>
<head>
<title>Text to speech Using JavaScrip</title>
<script type=”text/javascript” language=”javascript” src=”Speech.js”>
</script>
</head>
<body>
<input type=”text” id=”t1″/>
<input type=”button” id=”bt1″ name=”Speek Loud” value=”Speak Loud” onclick=”speakLoud()”/>
</body>
</html>
// JavaScript Document
Speech.js
function speakLoud()
{
var Obj = new ActiveXObject(“Sapi.SpVoice”);
var string=document.getElementById(“t1″).value;
alert(“You have entered”+string);
Obj.Speak(string, 1 );
}
Deter Users from Submitting a Form Twice
Hi in this article is I would like to explain what happens when a user clicks or submits the form, when user clicks the form the form is processed in the server and some action is going to take place but this might take place some milliseconds or even seconds depending upon the server load. If suppose user clicks a form multiple times assuming the form is not processing which is actually processing, so we should make them know they have actually clicked , preventing them to submit twice.
A user can be made to know that a form is submitted and is in processing in two ways.
a) By disabling a button when it is clicked once.
b) By freeing the page when the form is under submission.
By Disabling a Button when it is Clicked Once.
In this technique I use simple JavaScript technique to disable the button when a user clicks it once and displaying an text instead making user aware the form is under process.
| <html><head>
<title>By Disabling a Button when it is Clicked Once.</title> <script> function processButton(b) { b.disabled = true; b.value = ‘Submitting’; b.form.submit(); } </script> </head> <body> <form method=”get” action=”Disable.php”> <p> Name:<input > <input value=”Submit” onclick=”processButton(this);” /> </p> </form> </body> </html> |

By Freeing the page when the form is under submission.
This is most widely used technique where you will come across in many of the professional sites. I use bit of CSS for freezing the forms etc.
I use three CSS class to freeze and un freeze the form and vice versa.
a) FreezePanelOff : This Panel is the default style of the div tag this executes when you run the .html file.
b) FreezePanelOn : This panel gets activated only once the user clicks the button, once user clicks the button we are getting the id of both outer and inner div tag and check for its its existence and than later we are making the panel visible and gives necessary style.
c) InnerFreezePanel : This panel also gets activated once the user clicks the button it displays a rectangular style with a message .
What exactly Happens when a user Clicks a Button
Step 1:When a user clicks a button two things is going to take place the class which is set initially (FreezePanelOff) which is actually hidden should be visible and necessary styles should be given.
Step 2: The inner class displays in the center of the screen with necessary style sheet making the form freeze.
Freeze.html
| <html><head><title></title><style>
.FreezePanelOff { visibility: hidden; display: none; position: absolute; top: -100px; left: -100px; } .FreezePanelOn { position: absolute; top: 0px; left: 0px; visibility: visible; display: block; width: 100%; height: 100%; background-color: #3fe34; z-index: 999; filter:alpha(opacity=85); -moz-opacity:0.85; padding-top: 20%; } .InnerFreezePanel { text-align: center; width: 66%; background-color: #171; color: White; font-size: large; border: dashed 2px #111; padding: 9px; } </style> <script > function FreezeScreen(msg) { scroll(0,0); var outerPane = document.getElementById(‘FreezePanel’); var innerPane = document.getElementById(‘InnerFreezePanel’); if (outerPane) outerPane.className = ‘FreezePanelOn’; if (innerPane) innerPane.innerHTML = msg; } </script> </head> <body> <input value=”Submit” onclick=”FreezeScreen(‘Data is under process’);” />
<div align=”center” > <div > </div> </div>
</body> </html> |

Image Processing Using Java
Hi check this out to process image using Java …I thought its a tough one .but there are lot of standard functions available.
ImageProcess.java
package Image_Handling;
import java.awt.*;
import java.awt.image.*;
import javax.imageio.*;
import java.io.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.geom.*;
public class ImageProcess extends JFrame implements ActionListener
{
BufferedImage image;
JMenu file,edit;
JMenuItem open,save,exit,invert,bright,sharp,blur,edge,rotate;
JMenuBar bar;
JPanel panel;
Box box = Box.createVerticalBox();
JFileChooser chooser;
public ImageProcess()
{
super(“Image processing”);
try
{
show();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel=new JPanel();
setContentPane(panel);
setSize(500,500);
file=new JMenu(“File”);
open=new JMenuItem(“Open”);
save=new JMenuItem(“Save As..”);
exit=new JMenuItem(“Exit”);
file.add(open);
file.add(save);
file.addSeparator();
file.add(exit);
edit=new JMenu(“Edit”);
blur=new JMenuItem(“Blur”);
edit.add(blur);
sharp=new JMenuItem(“Sharpen”);
edit.add(sharp);
bright=new JMenuItem(“Brightness”);
edit.add(bright);
rotate=new JMenuItem(“Rotate”);
edit.add(rotate);
edge=new JMenuItem(“Edge Detect”);
edit.add(edge);
invert=new JMenuItem(“invert”);
edit.add(invert);
bar=new JMenuBar();
bar.add(file);
bar.add(edit);
setJMenuBar(bar);
open.addActionListener(this);
save.addActionListener(this);
exit.addActionListener(this);
invert.addActionListener(this);
//bright.addActionListener(this);
blur.addActionListener(this);
sharp.addActionListener(this);
rotate.addActionListener(this);
edge.addActionListener(this);
}
catch(Exception e)
{
System.out.println(“error:”+e.getMessage());
}
setContentPane(new JPanel()
{
public void paint(Graphics g)
{
g.drawImage(image,0,0,this);
}
});
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==exit)
{
System.exit(0);
}
if(ae.getSource()==save)
{
saveFile();
}
if(ae.getSource()==open)
{
openFile();
}
if(ae.getSource()==invert)
{
invertImage();
}
if(ae.getSource()==blur)
{
blurImage();
}
if(ae.getSource()==bright)
{
brightImage();
}
if(ae.getSource()==sharp)
{
sharpImage();
}
if(ae.getSource()==edge)
{
float[] elements =
{
0.0f, -1.0f, 0.0f,
-1.0f, 4.f, -1.0f,
0.0f, -1.0f, 0.0f
};
convolve(elements);
}
if(ae.getSource()==rotate)
{
if (image == null) return;
AffineTransform transform = AffineTransform.getRotateInstance(
Math.toRadians(5), image.getWidth() / 2, image.getHeight() / 2);
AffineTransformOp op = new AffineTransformOp(transform,
AffineTransformOp.TYPE_BILINEAR);
filter(op);
}
}
public void openFile()
{
try
{
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File(“.”));
int r = chooser.showOpenDialog(this);
if (r != JFileChooser.APPROVE_OPTION) return;
File f = chooser.getSelectedFile();
String name = f.getName();
//image=ImageIO.read(getClass().getResource(name));
image=ImageIO.read(chooser.getSelectedFile());
box.add(new JLabel(new ImageIcon(image)));
panel.add(new JScrollPane(box));
setSize(image.getWidth(), image.getHeight());
setTitle(name);
}
catch(Exception e)
{
}
}
public void saveFile()
{
try
{
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File(“.”));
int r = chooser.showSaveDialog(this);
if (r != JFileChooser.APPROVE_OPTION) return;
File f = chooser.getSelectedFile();
String name=f.getName();
ImageIO.write(image,”jpg”,new File(name));
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,e.getMessage());
}
}
public void invertImage()
{
byte negative[] = new byte[256];
for (int i = 0; i < 256; i++) negative[i] = (byte) (255 – i);
ByteLookupTable table = new ByteLookupTable(0, negative);
LookupOp op = new LookupOp(table, null);
filter(op);
}
public void sharpImage()
{
float[] elements ={0.0f, -1.0f, 0.0f,-1.0f, 5.f, -1.0f, 0.0f, -1.0f, 0.0f};
convolve(elements);
}
public void brightImage()
{
float a = 1.1f;
float b = -20.0f;
RescaleOp op = new RescaleOp(a, b, null);
filter(op);
}
public void blurImage()
{
float weight = 1.0f / 9.0f;
float[] elements = new float[9];
for (int i = 0; i < 9; i++) elements[i] = weight;
convolve(elements);
}
private void filter(BufferedImageOp op)
{
if (image == null) return;
BufferedImage filteredImage
= new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
op.filter(image, filteredImage);
image = filteredImage;
repaint();
}
private void convolve(float[] elements)
{
Kernel kernel = new Kernel(3, 3, elements);
ConvolveOp op = new ConvolveOp(kernel);
filter(op);
}
public static void main(String args[])throws Exception
{
new ImageProcess();
}
}
Download Code
Audio Player Using Java
Hey check this out ….i hav not implemented full functionality player but i hav tried my best just to play……
Audio.java
package Audio_Player;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
import java.applet.*;
public class Audio extends JFrame implements ActionListener,Runnable
{
JButton p,s;
AudioClip wavsong,t,j;
public Audio()throws Exception
{
super(“WavPlayer”);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
show();
JPanel pa=new JPanel();
setContentPane(pa);
pa.setBackground(new Color(100,200,100));
setLayout(null);
setSize(200,100);
setResizable(false);
p=new JButton(“Play”);
s=new JButton(“stop”);
p.setBounds(10,10,80,20);
add(p);
s.setBounds(100,10,80,20);
add(s);
wavsong=Applet.newAudioClip(new URL(“File:”+”ringin.wav”));
j=Applet.newAudioClip(new URL(“File:”+”j.wav”));
t=Applet.newAudioClip(new URL(“File:”+”tada.wav”));
p.addActionListener(this);
s.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
try
{
if(e.getActionCommand().equals(“Play”))
{
Thread.sleep(100);
j.play();
t.play();
wavsong.play();
}
else
{
wavsong.stop();
j.stop();
t.stop();
}
}
catch(Exception ae)
{
}
}
public void run()
{
}
public static void main(String args[])throws Exception
{
new Audio();
}
}
Screen shot using Java
Hi here is the program to take screen shot just like print screen in your windows.
Screenshot.java
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
public class Screenshot {
public static void main(String args[]) throws
AWTException, IOException {
// capture the whole screen
BufferedImage screencapture = new Robot().createScreenCapture(
new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()) );
// Save as JPEG
File file = new File(“screencapture.jpg”);
ImageIO.write(screencapture, “jpg”, file);
// Save as PNG
// File file = new File(“screencapture.png”);
// ImageIO.write(screencapture, “png”, file);
}
}
Download Code
VB Style Calendar in ASP.NET
Hi in this article I will create the old style calendar control which was there in VB 6.0 using little bit of JavaScript check out……..Actually this idea was not mine it was from my professor,any how check out………………
Default.aspx
| <%@ Page Language=”VB” AutoEventWireup=”false” CodeFile=”Default.aspx.vb” Inherits=”_Default” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <html xmlns=”http://www.w3.org/1999/xhtml” > <head id=”Head1″ runat=”server”> <script type=”text/javascript”> function displayCalendar() { var datePicker = document.getElementById(‘datePicker’); datePicker.style.display = ‘block’; }
</script> <style type=”text/css”> #datePicker { display:none; position:absolute; border:solid 2px black; background-color:white; } .content { width:400px; background-color:white; margin:auto; padding:10px; } html { background-color:silver; } </style> <title>Calendar with JavaScript</title> </head> <body> <form id=”form1″ runat=”server”> <div>
<asp:Label id=”lblEventDate” Text=”Event Date:” AssociatedControlID=”txtEventDate” Runat=”server” /> <asp:TextBox id=”txtEventDate” Runat=”server” />
<img src=”Images/Calendar.gif” onclick=”displayCalendar()” style=”width: 16px; height: 17px” />
<div id=”datePicker”> <asp:Calendar id=”calEventDate”
Runat=”server” /> </div>
<br /> <asp:Button id=”btnSubmit” Text=”Submit” Runat=”server” />
<hr />
<asp:Label id=”lblResult” Runat=”server” />
</div> </form> </body> </html>
|
Default.aspx.vb
| Partial Class _Default
Inherits System.Web.UI.Page Protected Sub calEventDate_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles calEventDate.SelectionChanged txtEventDate.Text = calEventDate.SelectedDate.ToString(“d”) End Sub
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click lblResult.Text = “You picked: ” & txtEventDate.Text End Sub End Class |
Sending SMS from ASP.NET Application
Hi In this article I am creating an application from which we can send free sms just like www.way2sms.com [Remember you just have registered in way2sms.com before trying this code]. It involes a little trick which I will explain when I am free please excuse for that and I am not explain much about web service I am directly sharing my code which I have implemented for my project check out and please give your feedback.

SMS.aspx
| <%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”SMS.aspx.cs” Inherits=”SMS” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” > <head runat=”server”> <title>Untitled Page</title>
</head> <body> <form id=”form1″ runat=”server”> <div>
<b>Sending SMS from your ASP.NET Application<br /> <br /> <br /> <asp:Label ID=”Label1″ runat=”server” Text=”User Name”></asp:Label> <asp:TextBox ID=”TextBox4″ runat=”server”></asp:TextBox> <br />
<br /> <asp:TextBox ID=”TextBox5″ runat=”server”></asp:TextBox> <br /> <br /> <asp:Label ID=”Label3″ runat=”server” Text=”Moble Number”></asp:Label> <asp:TextBox ID=”TextBox3″ runat=”server”></asp:TextBox> <br /> <br /> <center>Enter your text :</center> </b></div>
<p style=”width: 698px”> <b <asp:TextBox ID=”TextBox6″ runat=”server” Height=”105px” Width=”296px”></asp:TextBox> </b> </p>
<asp:Label ID=”Label4″ runat=”server”></asp:Label> <asp:Button ID=”Button1″ runat=”server” onclick=”Button1_Click” Text=”Send” /> </form> </body> </html> |
SMS.aspx.cs
| using System;
using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls;
public partial class SMS : System.Web.UI.Page {
protected void Button1_Click(object sender, EventArgs e) { JavaAdd.SendSMS js = new JavaAdd.SendSMS(); string username, password, number, data; data = TextBox6.Text; username = TextBox6.Text; password = TextBox5.Text; number = TextBox3.Text; Label4.Text = js.sendSMSToMany(username, password, number, data);
} }
|
Creating CAPTCHA using PHP
Hi in this article I am going to create a captcha using php. It took some time to study and implement …. it is quite interesting to know how it works check it out…….. ,you would have observed captcha in several websites like in form submission and importantly in gmail once u enter a wrong password more than thrice you would have got this …………..Check out……Hey one more important thing in this article I have used AJAX to submit ur form data and process it. I think no further information is required to know AJAX has my Blog explains all the fundamentals of AJAX if not check in my categories.
Steps involved in creating captcha
Step 1:It simply works by generating a random string and putting it into an image. We will use the function microtime() and mktime() as parameter for md5() (you can also use rand(0,999)) function to generate a number. This will be encrypted using md5().With this 32 character long encrypted string will generate using substring we will cut it 5 long string .This will be our random text generated.
$md5_hash = md5(rand(0,999));
$security_code = substr($md5_hash, 15, 5);
Step 2:Insert the newly generated string into session variable.
$_SESSION["security_code"] = $security_code;
Step 3:Using stabdard function ImageCreate create an image with necessary parameters
Step 4: Using standard functions to allocate, fill, set the string and,set the shape of an image, the colors ImageColorAllocate(),ImageString(),ImageRectangle() whichever is your favorite I have choose the standard colors.

Captcha-Form.html
<html>
<head>
<title>Creating CAPTCHA Using PHP</title>
<script type=”text/javascript”>
var xhr;
if(window.ActiveXObject)
{
try
{
xhr = new ActiveXObject(“Microsoft.XMLHTTP”);
}
catch (e)
{
xhr = false;
}
}
else
{
try
{
xhr = new XMLHttpRequest();
}
catch (e)
{
xhr = false;
}
}
function sendRequest(url)
{
var value = document.getElementById(“txtCaptcha”).value;
var url = “http://localhost/captcha.php”;
var newurl=url+”?”+”txtCaptcha=”+value;
if (xhr)
{
xhr.open(“POST”,newurl,true);
xhr.setRequestHeader(“Content-Type”, “application/x-www-form- urlencoded”);
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4 && xhr.status == 200)
{
document.getElementById(‘result’).innerHTML = xhr.responseText;
img = document.getElementById(‘imgCaptcha’);
img.src = ‘create_image.php?’ + Math.random();
}
}
}
xhr.send(“txtCaptcha=”+value);
}
</script>
</head>
<body>
<form name=”frmCaptcha”>
<fieldset>
<label for=”captcha”>Captcha</label>
<input name=”txtCaptcha” value=”" maxlength=”10″ size=”32″ />
<img src=”create_image.php” />
<input value=”Captcha Test”
onclick=”sendRequest()” />
<div> </div>
</fieldset>
</form>
</body>
</html>
create_image.php
<?
session_start();
create_image();
exit();
function create_image()
{
$md5_hash = md5(rand(0,999));
$security_code = substr($md5_hash, 15, 5);
$_SESSION["security_code"] = $security_code;
$width = 100;
$height = 20;
$image = ImageCreate($width, $height);
$white = ImageColorAllocate($image, 255, 255, 255);
$black = ImageColorAllocate($image, 0, 0, 0);
$grey = ImageColorAllocate($image, 204, 204, 204);
ImageFill($image, 0, 0, $black);
ImageString($image, 3, 30, 3, $security_code, $white);
ImageRectangle($image,0,0,$width-1,$height-1,$grey);
//imageline($image, 0, $height/2, $width, $height/2, $grey);
//imageline($image, $width/2, 0, $width/2, $height, $grey);
header(“Content-Type: image/jpeg”);
ImageJpeg($image);
ImageDestroy($image);
}
?>
captcha.php
<?
session_start();
if ($_REQUEST["txtCaptcha"] == $_SESSION["security_code"])
{
echo “<h1>Test successful!</h1>”;
}
else
{
echo “<h1>Test failed! Try again!</h1>”;
}
Automatic Update with the Timer
Timer control can be used to update page automaticly . Instead of requiring the user to perform an action in order to trigger updates, the Timer control will initiate the postback automatically.
The Timer control can execute client-side events at precise intervals, such as refreshing an UpdatePanel every x seconds.
Timer-Demo.aspx
| <body>
<form id=”form1″ runat=”server”> <div>
</div> <asp:ScriptManager ID=”ScriptManager1″ runat=”server”> </asp:ScriptManager> <br /> <asp:UpdatePanel ID=”UpdatePanel1″ runat=”server”> <ContentTemplate> <asp:Timer ID=”Timer1″ runat=”server” Interval=”100″ > </asp:Timer> <div style=”border-style:solid;background-color:Aqua;”> <asp:Label ID=”Label1″ runat=”server”></asp:Label> </div> <asp:Button ID=”Button1″ runat=”server” Text=”Button” /> <br /> </ContentTemplate> </asp:UpdatePanel> protected void Page_Load(object sender, EventArgs e) { Label1.Text = DateTime.Now.ToString(); } |

Image zooming using mouse scroll
Hi recently i got a task from my friend to code for zooming image using JavaScript for his project….I tried a lot to do his work finally i did his work taught of sharing with u……………
firstly we have to check for the value of mouse scroll and than later
based on the mouse up and down of mouse scroll we have to code……………..I took lot of help from Internet to code this stuff…………..just try it out…………….
| <html><head>
<title>Image Zooming using Mouse Scroll </title> <script src=”zoom-image.js”> </script> </head> <body> <img src=”../../../img.jpg” width=”133″height=”142″ /> </body> <div> </div> </html> |
zoom-image.js
| function zoomin(){
alert(“Zoom In”); if(parent.document.body.style.zoom!=0) parent.document.body.style.zoom*=1.2; else parent.document.body.style.zoom=1.2; } function zoomout() { alert(“Zoom Out”); if(parent.document.body.style.zoom!=0) { parent.document.body.style.zoom*=0.833; } else { parent.parent.document.body.style.zoom=0.833; } } function handle(delta) { if (delta < 0) { alert(“Mouse Back”); zoomout(); } else if(delta > 0) { alert(“Mouse Front”); zoomin(); } else { alert(“notinh”); } } /** Event handler for mouse wheel event. */ function wheel(event) { var delta = 0; if (!event) event = window.event; if (event.wheelDelta) { delta = event.wheelDelta/120; if (window.opera) delta = -delta; } else if (event.detail) { delta = -event.detail/3; } if (delta) handle(delta); if (event.preventDefault) event.preventDefault(); event.returnValue = false; } if (window.addEventListener) /** DOMMouseScroll is for mozilla. */ window.addEventListener(‘DOMMouseScroll’, wheel, false); /** IE/Opera. */ window.onmousewheel = document.onmousewheel = wheel; |


