Tuesday, 12 June 2012

Javascript First Program

How to take input from user in javascript ?

In this post i am going to write a java-script code to take a input from the user,
nothing fancy, just a simple yes or no input,
so here is the code to do that

so first comes the HTML, where the javascript file is going to be called,

<title>Cookie Alert !</title>  
<script type="text/javascript" src="Confirm_script.js">    

and here is what goes into Confirm_script.js

var ans = prompt("Are you sure you want to do that",""); 
if (ans){                                                
alert("You said " + ans)                             
alert("Y u no answer ???")                           

No comments: