Tuesday, 17 September 2024

WRITE A JAVASCRIPT TO PRINT CUBE OF GIVEN NUMBER

 WRITE A JAVASCRIPT TO PRINT SQUARE OF GIVEN NUMBER

CODE:-

<html>

<head>

<title>Square</title>

<style type="text/css">

body{

background-color:lightgreen;

}

.tab{

background-color:grey;

color:;

text-transform:capitalize;

}

.v1{

text-align:center;

background-color:orange;

}

.v2{

text-align:center;

background-color:yellow;

}

</style>

<script type="text/javascript">

function check()

{

var no=parseInt(document.f1.no.value);

var ans=no*no*no;

document.f1.ans.value=ans;

return false;

}

</script>

</head>

<body>

<center>

<form name="f1" method="post" onsubmit="return check()">

<table border="1" cellspacing="0" class="tab">

<tr class="v1">

<th colspan="2">to print square of given number</th>

</tr>

<tr>

<th>enter number:-</th>

<td><input type="text" name="no" size="5" style="border-radius:10px;"></td>

</tr>

<tr class="v1">

<td colspan="2">

<input type="submit" name="submit" value="Submit" style="border-radius:8px;background-color:red;color:white;font-weight:bold;border-color:green;">

<input type="reset" name="reset" value="Reset" style="border-radius:8px;background-color:red;color:white;font-weight:bold;border-color:green;">

</td>

</tr>

<tr>

<th>square of given number:-</th>

<td><input type="text" name="ans" size="5" style="border-radius:10px;"></td>

</tr>

</table>

</form>

</center>

</body>

</html>


WRITE A JAVASCRIPT TO PRINT SQUARE OF GIVEN NUMBER


CODE:-

<html>

<head>

<title>Square</title>

<style type="text/css">

body{

background-color:lightgreen;

}

.tab{

background-color:grey;

color:;

text-transform:capitalize;

}

.v1{

text-align:center;

background-color:orange;

}

.v2{

text-align:center;

background-color:yellow;

}

</style>

<script type="text/javascript">

function check()

{

var no=parseInt(document.f1.no.value);

var ans=no*no;

document.f1.ans.value=ans;

return false;

}

</script>

</head>

<body>

<center>

<form name="f1" method="post" onsubmit="return check()">

<table border="1" cellspacing="0" class="tab">

<tr class="v1">

<th colspan="2">to print square of given number</th>

</tr>

<tr>

<th>enter number:-</th>

<td><input type="text" name="no" size="5" style="border-radius:10px;"></td>

</tr>

<tr class="v1">

<td colspan="2">

<input type="submit" name="submit" value="Submit" style="border-radius:8px;background-color:red;color:white;font-weight:bold;border-color:green;">

<input type="reset" name="reset" value="Reset" style="border-radius:8px;background-color:red;color:white;font-weight:bold;border-color:green;">

</td>

</tr>

<tr>

<th>square of given number:-</th>

<td><input type="text" name="ans" size="5" style="border-radius:10px;"></td>

</tr>

</table>

</form>

</center>

</body>

</html>


WRITE A JAVASCRIPT TO PRINT ODD NUMBER FROM 1 TO 10

 WRITE A JAVASCRIPT TO PRINT EVEN NUMBER FROM 1 TO 10

CODE:-

<html>

<head>

<title>Even No</title>

<script type="text/javascript">

var i=1;

document.write("EVEN NUMBERS");

for(i=1;i<=10;i++)

{

if(i%2!=0)

{

document.write("<br>"+i);

}

}

</script>

</head>

<body>

</body>

</html>


WRITE A JAVASCRIPT TO PRINT EVEN NUMBER FROM 1 TO 10


CODE:-

<html>

<head>

<title>Even No</title>

<script type="text/javascript">

var i=1;

document.write("EVEN NUMBERS");

for(i=1;i<=10;i++)

{

if(i%2==0)

{

document.write("<br>"+i);

}

}

</script>

</head>

<body>

</body>

</html>


Monday, 16 September 2024

WRITE A JAVASCRIPT TO CHECK USERID AND PASSWORD IS SAME OR NOT

 <!DOCTYPE html>

<html>

<body>

<h2> Write a program to check Uid and Password 

are X and Y (X and Y will be fixed strings of your choice). </h2>


<table border="2px">

<tr>

<th>Enter UserName: </th>

<td><input type="text" name="txt_username" 

id="username"/></td>

</tr>

<tr>

<th>Enter Password: </th>

<td><input type="password" name="txt_password" 

id="password"/></td>

</tr>

<tr>

<td colspan="2" align="center"><input type="submit" 

value="Login" onclick="findLogin()"/></td>

</tr>

</table>

<script language="JavaScript">

function findLogin() {

var unm=document.getElementById("username").value;

var pwd=document.getElementById("password").value;

if(unm == "ANAND" && pwd == "ANAND") {

alert("Login Successfull");

}

else {

document.write("UserName or Password do not match");

}

}

</script>


</body>

</html>


WRITE A JAVASCRIPT TO READ CHARACTER AND PRINT MALE OR FEMALE OR INVALID CHARACTER

 <!DOCTYPE html>

<html>

<body>

<h2> Read a character and print Male or Female based on M or F and otherwise "Invalid Character". </h2>


<table border="2px">

<tr>

<th>Enter character: </th>

<td><input type="text" name="txt_string" id="charecter" maxlength="1" size="1"/></td>

</tr>

<tr>

<td colspan="2" align="center">

<input type="submit" value="click me" onclick="findMale()"/></td>

</tr>

</table>

<script language="JavaScript">

function findMale() {

var ch = document.getElementById("charecter").value;

if(ch == "M" || ch == "m") {

document.write("You have entered: "+ch+" "+"is Male.");

}

else if(ch == "F" || ch == "f") {

document.write("You have entered: "+ch+" "+"is Female.");

}

else {

document.write("You have entered: "+ch+" "+" which is invalid choice.");

}

}

</script>


</body>

</html>


WRITE A JAVASCRIPT TO READ A CHARACTER AND CHECK WHETHER IT IS A VOWEL OR NOT

 <!DOCTYPE html>

<html>

<body>

<h2> Read a character and check whether it is a Vowel or not. </h2>


<table border="2px">

<tr>

<th>Enter character: </th>

<td><input type="text" name="txt_string" id="charecter" maxlength="1" size="1"/></td>

</tr>

<tr>

<td colspan="2" align="center"><input type="submit" value="click me" onclick="findVowel()"/></td>

</tr>

</table>

<script language="JavaScript">

function findVowel() {

var ch = document.getElementById("charecter").value;

if(ch=="A" || ch=="E" || ch=="I" || ch=="O" || ch=="U" || ch=="a" || ch=="e" || ch=="i" || ch=="o" || ch=="u")

{

alert("You have entered: "+ch+" "+"is VOWEL");

}

else {

alert("You have entered: "+ch+" "+"is not VOWEL");

}

}

</script>


</body>

</html>


WRITE A JAVASCRIPT TO CHECK INPUTED STRING IN THAT STRING WHICH IS LARGER OR NOT

 <!DOCTYPE html>

<html>

<body>


<p>Click the button to return the number of characters in the string "Hello World!".</p>

Enter First String: <input type="text" name="txt_fstring" id="first"/> <br/>

Enter Second String: <input type="text" name="txt_sstring" id="second"/> <br/>

<button onclick="myFunction()">Try it</button>


<!--<p id="demo"></p>-->


<script language="JavaScript">

function myFunction() {

  var str = document.getElementById("first").value;

  var str1 = document.getElementById("second").value;

  

  var n = str.length;

  var n1 = str1.length;

  

  //document.getElementById("demo").innerHTML = str +" "+ n +" "+ str1 +" "+ n1;


  if(n > n1) {

document.write("First String is larger than Second");

  }

  else if(n< n1){

document.write("Second String is larger than First");

  }

  else {

document.write("Both are Same");

}

}

</script>


</body>

</html>


WRITE A JAVASCRIPT TO USER ENTERED DATE IS FUTURE DATE OR PAST DATE

 <html>

<head>

<title></title>

</head>

<body>

<h2>Print the day of the month from the system and user entered dates</h2>

Enter Date: <input type="date" name="dt_date" id="dt_date"> <br/>

<input type="submit" value="Click Me" onclick="myFunction()"/>

<script language="JavaScript">

function myFunction() {

var date = new Date();


mydate=new Date(document.getElementById('dt_date').value);


if(date < mydate) {

  alert(" The given date is Future Date");

}

else {

alert("The given date is Past Date");

}

}

</script>

</body>

</html>

WRITE A JAVASCRIPT TO PRINT DAY OF THE MONTH FROM THE SYSTEM AND USER ENTERED DATES

 <html>

<head>

<title></title>

</head>

<body>

<h2>Print the day of the month from the system and user entered dates</h2>

Enter Date: <input type="date" name="dt_date" id="dt_date"> <br/>

<input type="submit" value="Click Me" onclick="myFunction()"/>

<script language="JavaScript">

function myFunction() {

var date=new Date(document.getElementById('dt_date').value);

var day=date.getDate();

var dayname=date.getDay();

if(dayname==1) {

document.write("You have selected: "+date+" "+"Monday");

}

else if(dayname==2) {

document.write("You have selected: "+date+" "+"Tuesday");

}

else if(dayname==3) {

document.write("You have selected: "+date+" "+"Wednesday");

}

else if(dayname==4) {

document.write("You have selected: "+date+" "+"Thursday");

}

else if(dayname==5) {

document.write("You have selected: "+date+" "+"Friday");

}

else if(dayname==6) {

document.write("You have selected: "+date+" "+"Saturday");

}

else {

document.write("You have selected: "+date+" "+"Sunday");

}

}

</script>

</body>

</html>

Sunday, 15 September 2024

WRITE A JAVASCRIPT TO PRINT BANK MENU





1.DEPOSIT

2.WITHDRAWAL

3.ACCOUNT DETAILS

4.EXIT

CODE:-

<html>

<head>

<title>Bank Menu</title>

<style type="text/css">

body{

background-color:lightgreen;

}

.tab{

background-color:grey;

color:;

text-transform:capitalize;

}

.v1{

text-align:center;

background-color:orange;

}

.v2{

text-align:center;

background-color:yellow;

}

</style>

<script type="text/javascript">

function check()

{

var no=document.f1.ch.value;

var bal=10000,tot=0;

if(no==1)

{

var tot=parseInt(prompt("Enter Deposit Amount"));

document.f1.dep.value=tot;

var totbl=bal+tot;

document.f1.totbl.value=totbl;

}

else if(no==2)

{

var wit=parseInt(prompt("Enter Withdrawal Amount"));

document.f1.wit.value=wit;

var ans=bal-wit;

document.f1.totbl.value=ans;

}

else if(no==3)

{

document.write("<br> Name:- Vivek L Parmar");

}

else if(no==4)

{

document.write("Exited Account");

}

else

{

alert("Invalid Choice");

}

return false;

}

</script>

</head>

<body>

<center>

<form name="f1" method="post" onsubmit="return check()">

<table border="1" cellspacing="0" class="tab">

<tr class="v1">

<th colspan="2">bank menu</th>

</tr>

<tr>

<th colspan="2">1.deposit</th>

</tr>

<tr>

<th colspan="2">2.withdrawal</th>

</tr>

<tr>

<th colspan="2">3.account detalis</th>

</tr>

<tr>

<th colspan="2">4.exit</th>

</tr>

<tr class="v2">

<th>enter your choice:-</th>

<td><input type="text" name="ch" size="5" style="border-radius:15px;"></td>

</tr>

<tr class="v1">

<td colspan="2">

<input type="submit" name="submit" value="Submit" style="border-radius:8px;background-color:red;color:white;font-weight:bold;border-color:green;">

<input type="reset" name="reset" value="Reset" style="border-radius:8px;background-color:red;color:white;font-weight:bold;border-color:green;">

</td>

</tr>

<tr>

<th>deposited amount:</th>

<td><input type="text" name="dep"></td>

</tr>

<tr>

<th>withdrawal amount:</th>

<td><input type="text" name="wit"></td>

</tr>

<tr>

<th>total balance:</th>

<td><input type="text" name="totbl"></td>

</tr>

</table>

</form>

</center>

</body>

</html>


WRITE A JAVASCRIPT TO PRINT MONTH NAME USING SWITCH STATEMENT



CODE :-

<html>

<head>

<title>Month</title>

<script type="text/javascript">

function check()

{

var no=parseInt(prompt("Enter Number="));

switch(no)

{

case 1:

document.write("January");

break;

case 2:

document.write("February");

break;

case 3:

document.write("March");

break;

case 4:

document.write("April");

break;

case 5:

document.write("May");

break;

case 6:

document.write("June");

break;

case 7:

document.write("July");

break;

case 8:

document.write("August");

break;

case 9:

document.write("September");

break;

case 10:

document.write("October");

break;

case 11:

document.write("November");

break;

case 12:

document.write("December");

break;

default:

document.write("Invalid Choice");

}

}

</script>

</head>

<body>

<form name="form1" method="post" onsubmit="return check()">

<input type="submit" name="submit" value="Submit">

</form>

</body>

</html>


WRITE A JAVASCRIPT TO PRINT WEEKDAY USING SWITCH STATEMENT


CODE :-

<html>

<head>

<title>Weekday</title>

<script type="text/javascript">

function check()

{

var no=parseInt(prompt("Enter Number="));

switch(no)

{

case 1:

document.write("Monday");

break;

case 2:

document.write("Tuesday");

break;

case 3:

document.write("Wednesday");

break;

case 4:

document.write("Thursday");

break;

case 5:

document.write("Friday");

break;

case 6:

document.write("Saturday");

break;

case 7:

document.write("Sunday");

break;

default:

document.write("Invalid Choice");

}

}

</script>

</head>

<body>

<form name="form1" method="post" onsubmit="return check()">

<input type="submit" name="submit" value="Submit">

</form>

</body>

</html>