Monday, May 20, 2019

Swapping Two Numbers in javascript | Swap Program in JavaScript

Swap two Number Program in JavaScript - In this program, we write how to swap two number using third variable in javascript. Swapping two numbers in javascript program to swap variable values without using a temporary variable. Swap program means the value of one variable is assigned to another and vice versa.


Swapping Two Numbers in javascript
Swap Program in JavaScript


Example of Swap Program in JavaScript:

<html>
<head>
<title> Swap Program in JavaScript</title>
</head>
<style>
body{

background-color:#f47a42;

color: white;

width:500px;

height:200px;

border:1px solid black;

position:absolute;

top:150px;

left:100px;

}
</style>
<h1><center>Simple Swap Number Program</center></h1>
<script type="text/javascript">
function swap(){
var a,b,c;
a=Number(document.getElementById("first").value);
b=Number(document.getElementById("second").value);
c=a;
a=b;
b=c;
document.getElementById("answer1").value= a;
document.getElementById("answer2").value= b;
}
</script>

Value of a: <input id="first">
Value of b: <input id="second"></br></br>
<button onclick="swap()">Swap</button></br></br>
Value of a: <input id="answer1">
Value of b: <input id="answer2">
</body>
</html>

Friday, May 17, 2019

Feedback Form in HTML and CSS | Student Feedback Form in HTML Code

In this tutorial, we will learn how to create feedback form in HTML and CSS. Freely learn and create student feedback form in HTML code. Easy to make an HTML form, just copy the source code of feedback form and paste in your text editor. If you want to change the HTML feedback form, you can. Let's start the code-



Feedback Form in HTML and CSS
Feedback Form in HTML and CSS


Feedback Form Source Code:

<html>
<head>  
<title>Forms</title>
<style type="text/css">
body {  
font-family: arial;  
background-color: rgb(185,179,175);
legend {
color: green;
}
label {
color: black;
}
h1 {
background-color:#E86F67; 
color: #2A363B;
}
</style>  
</head> <body>
<h1><center>Welcome To CodeTextPro</center></h1>  
<form action="https://www.codetextpro.com/p/contact-us.html" method="post">   
<fieldset>    
<legend>     
Your Details:    
</legend>    
<label>     
Name:     <input type="text" name="name" size="30" maxlength="100">    
</label>    
<br />    
<label>     
Email:     <input type="email" name="email" size="30" maxlength="100">    
</label>    
<br />   
</fieldset>   
<br />   
<fieldset>    
<legend>     Your Review:    </legend>    
<p>     
<label for="hear-about">      
How did you hear about us?     
</label>     
<select name="referrer" id="hear-about">      
<option value="google">Google</option>      
<option value="friend">Friend</option>      
<option value="advert">Advert</option>      
<option value="other">Other</option>
</select>
</p>
</p>

 Would you visit again?     
<br />     
<label>      
<input type="radio" name="rating" value="yes" />      
Yes     
</label>     
<label>      
<input type="radio" name="rating" value="no" />      
No     
</label>     
<label>      
<input type="radio" name="rating" value="maybe" />      
Maybe     
</label>    
</p>    
<p>     
<label for="comments">      
Comments:     
</label>     
<br />     
<textarea rows="4" cols="40" id="comments">     
</textarea>   
 </p>    
<label>     
<input type="checkbox" name="subscribe" checked="checked" />      
Sign me up for email updates    
</label>    
<br />    
<input type="submit" value="Submit review" />   
</fieldset>  
</form> 
</body> 
</html> 



Monday, May 13, 2019

Simple JavaScript Currency Converter | Currency Converter using JavaScript

In this tutorial, we will create a Simple Currency Converter using Javascript. I'm trying to make a currency converter that converts between several different currencies on change. It uses some pre-determined exchange rates. JavaScript is a scripting or programming language that allows you to implement complex things on web pages. In this program, you will learn how Currency Converter using JavaScript. So, let start the Simple JavaScript Currency Converter.



Currency Converter using JavaScript
Currency Converter using JavaScript





JavaScript Currency Input:

<html>
<head>

<!-- *****************start css part***************** -->
<style>
body
{
width:400px;

border:1px solid white;

position:absolute;

top:150px;
left:100px;
background-color:black;
color:white;
}

</style>
<!-- *****************end css part***************** -->



<!-- *****************start javascript part***************** -->
<script>
function check(){
var a,b,c,result;
b=Number(document.getElementById("selec").value);
c=Number(document.getElementById("selec2").value);
a=Number(document.getElementById("a").value);
if(b==c)
{
alert("You have entered Two Same country: Please try again!!!");
}
else
{
switch (b)
{

<!-- *****************start case 1***************** -->
case 1:
{
if(b==1 && c==2)
{
result=83.70*a;
}
else if(b==1 && c==2)
{
result=64.94*a;
}
else if(b==1 && c==3)
{
result=112.11*a;
}
else if(b==1 && c==4)
{
result=0.85*a;
}
else if(b==1 && c==5)
{
result=0.85*a;
}
break;
}
<!-- *****************end case 1***************** -->



<!-- *****************start case 2***************** -->
case 2:
{
if(b==2 && c==1)
{
result=0.01*a;
}
else if(b==2 && c==3)
{
result=0.78*a;
}
else if(b==2 && c==4)
{
result=1.34*a;
}
else if(b==2 && c==5)
{
result=0.01*a;
}
break;
}
<!-- *****************end case 2***************** -->



<!-- *****************start case 3***************** -->
case 3:
{
if(b==3 && c==1)
{
result=0.02*a;
}
else if(b==3 && c==2)
{
result=1.29*a;
}
else if(b==3 && c==4)
{
result=1.73*a;
}
else if(b==3 && c==5)
{
result=0.01*a;
}
break;
}
<!-- *****************end case 3***************** -->



<!-- *****************start case 4***************** -->
case 4:
{
if(b==4 && c==1)
{
result=0.01*a;
}
else if(b==4 && c==2)
{
result=0.75*a;
}
else if(b==4 && c==3)
{
result=0.58*a;
}
else if(b==4 && c==5)
{
result=0.01*a;
}
break;
}
<!-- *****************end case 4***************** -->



<!-- *****************start case 5***************** -->
case 5:
{
if(b==5 && c==1)
{
result=1.18*a;
}
else if(b==5 && c==2)
{
result=98.69*a;
}
else if(b==5 && c==3)
{
result=76.57*a;
}
else if(b==5 && c==4)
{
result=132.20*a;
}
break;
}
<!-- *****************end case 5***************** -->


}
}
document.getElementById("answer").value=result;
}
</script>
<!-- *****************end javascript part***************** -->




</head>
<body>
<center>
Enter Your Currency Amount:<br>
<input type="number" id="a" placeholder="00.00">
<br><br>
Select Your Currency Country:<br><select id="selec">
<option value="0">-------</option>
<option value="1">America</option>
<option value="2">Bangadesh</option>
<option value="3">India</option>
<option value="4">Japan</option>
<option value="5">Franch</option>
</select><br><br>
Chose The Converter Country:<br><select id="selec2">
<option value="0">-------</option>
<option value="1">America</option>
<option value="2">Bangadesh</option>
<option value="3">India</option>
<option value="4">Japan</option>
<option value="5">Franch</option></select><br><br>
          <input type="button" onclick="check()" value="Convert"></button>
  <br>The Converted Amount is:<br>
<input type="number" id="answer" placeholder="00.00">
</center>
</body>
</html>



Currency Converter Output:


Simple JavaScript Currency Converter
Simple JavaScript Currency Converter 




Simple JavaScript Currency Converter
Simple JavaScript Currency Converter 



JavaScript Add Rows To Table Dynamically || Dynamically Add Rows To Table Using JavaScript

In this Example, you will see that dynamically add rows to table using javascript. Used this code you will insert an unlimited number of row in an HTML table. Used JavaScript Add Rows To Table Dynamically. How javascript insert row at end of table you will learn this tutorial in this program. Create table using javascript.






When you run this program in your computer browser, you will see that 'Enter number of rows' types any number in the box. If you enter 5, then click generate. Five number of row create immediately in the table form.

JavaScript Add Rows To Table Dynamically
Dynamically Add Rows To Table Using JavaScript

Dynamically Add Rows To Table Using JavaScript
JavaScript Add Rows To Table Dynamically




<html>
<head>

<!-- ***********************Start CSS Part to Design********************** -->
<style>table{width:400px;border:1px solid red;position:absolute;top:150px;left:10px;}th{background-color:black;color: white;}tr{height:30px;background-color:green;}</style>
<!-- ******************End CSS Part************************  -->


<!-- ******************Start JavaScript Part to Call Function************************  -->
<script> function f(){    var x = document.getElementById("t1").value;    for(var i=0;i<x;i++) {   var str="<tr><td></td><td></td><td></td></tr>"; document.getElementById("tab").innerHTML+=str;         }}</script>
<!-- ******************End JavaScript Part************************  -->

</head>
<dody>
<body bgcolor="orange">
<div id="d1"><p>Enter number of rows</p><input type="text" value="" id='t1'>
</div>
<br><div id="d2"><input type="button" name="Generate" value="Generate" onclick="f()" />
</div>
<table id='tab'><tr><th>id</th><th>Name</th><th>Address</th></tr>
</table>
</body>
</html>

Monday, April 29, 2019

Top Interview Aptitude Questions With Answer

If D is the brother of B, how B is related to C? To answer this question which of the statements is/are necessary? The son of D is the grandson of C.B is the sister of D. 


  • Only 1
  • Only 2
  • Either 1 or 2
  • 1 and 2 both are required
 Answer: 1 and 2 both are required



The total of the ages of Amar, Akbar, and Anthony is 80 years. What was the total of their ages three years ago? 


  • 71 years  
  • 72 years
  • 74 years
  • 77 years
Answer: 71 years 


A's son B is married with C whose sister D is married to E the brother of B. How D is related to A? 


  • Sister
  • Daughters-in-law 
  • Sister-in-law
  • Cousin
Answer: Daughters-in-law


Pointing to a woman, Abhijit said, "Her granddaughter is the only daughter of my brother." How is the woman related to Abhijit? 


  • Sister
  • Grandmother
  • Mother-in-law
  • Mother
Answer: Mother



2, 7, 27, 107, 427, ? 


  • 1262
  • 1707      
  • 4027
  • 4207
Answer: 1707


Pointing to Gopi, Nalni says, "I am the daughter of the only son of his grandfather." How Nalni is related to Gopi? 


  • Niece
  • Daughter
  • Sister        
  • Cannot be determined
Answer: Sister


An institute organized a fete and 1/5 of the girls and 1/8 of the boys participated in the same. What fraction of the total number of students took part in the fete?


  • 2/13
  • 13/40
  • Data inadequate 
  • None of these
Answer: Data inadequate 


6, 17, 39, 72, ?


  • 83
  • 94
  • 116  
  • 127
Answer: 116 


Anupam said to a lady sitting in a car, "The only daughter of the brother of my wife is the sister-in-law of the brother of your sister." How the husband of the lady is related to Anupam?


  • Maternal uncle
  • Uncle
  • Father
  • Son-in-law  
Answer: Son-in-law



Pointing to Varman, Madhav said, "I am the only son of one of the sons of his father." How is Varman related to Madhav?


  • Nephew
  • Uncle
  • Father or Uncle  
  • Father
Answer: Father or Uncle


625, 5, 125, 25, 25, ?, 5


  • 5
  • 25
  • 125    
  • 625
Answer: 125 


A and B are children of D. Who is the father of A? To answer this question which of the statements (1) and (2) is necessary? C is the brother of A and the son of E.F is the mother B.


  • Only (1)
  • Only (2)    
  • Either (1) or (2)
  • (1) and (2) both
Answer: Only (2)


Amit said - "This girl is the wife of the grandson of my mother". How is Amit related to the girl?


  • Brother
  • Grandfather
  • Husband
  • Father-in-law    
Answer: Father-in-law 



24, 60, 120, 210, ?


  • 300
  • 336    
  • 420
  • 525
Answer: 336 


2,3,8,27, 112,?


  • 226
  • 339
  • 452
  • 565    
Answer: 565  



11, 10, ?, 100, 1001, 1000, 10001


  • 101      
  • 110
  • 111
  • None of these
Answer: 101 


13, 32, 24, 43, 35, ?, 46, 65, 57, 76


  • 45
  • 52
  • 54   
  • 55
Answer: 54


Deepak said to Nitin, "That boy playing with the football is the younger of the two brothers of the daughter of my father's wife." How is the boy playing football related to Deepak?


  • Son
  • Brother     
  • Cousin
  • Brother-in-law
Answer: Brother


Two bus tickets from city A to B and three tickets from city A to C cost Rs. 77 but three tickets from city A to B and two tickets from city A to C cost Rs. 73. What are the fares for cities B and C from A?


  • Rs. 4, Rs. 23
  • Rs. 13, Rs. 17    
  • Rs. 15, Rs. 14
  • Rs. 17, Rs. 13
Answer: Rs. 13, Rs. 17


P is the mother of K; K is the sister of D; D is the father of J. How is P related to J?


  • Mother
  • Grandmother     
  • Aunt
  • Data inadequate
Answer: Grandmother 


3, 10, 101,?

  • 10101
  • 10201
  • 10202    
  • 11012
Answer: 10202

SCD, TEF, UGH, ____, WKL

  • CMN
  • UJI
  • VIJ         
  • IJT
Answer: VIJ


Introducing a woman, Shashank said, "She is the mother of the only daughter of my son." How that woman is related to Shashank?

  • Daughter
  • Sister-in-law
  • Wife
  • Daughter-in-law    
Answer: Daughter-in-law


Pointing to Varman, Madhav said, "I am the only son of one of the sons of his father." How is Varman related to Madhav? 

  • Nephew
  • Uncle
  • Father or Uncle    
  • Father
Answer: Father or Uncle


Look at this series: 7, 10, 8, 11, 9, 12, ... What number should come next?

  • 7
  • 10    
  • 12
  • 13
Answer: 10 


120, 99, 80, 63, 48, ?
  • 35    
  • 38
  • 39
  • 40
Answer: 35


On weekends, Mr. Sanchez spends many hours working in his vegetable and flower gardens. Mrs. Sanchez spends her free time reading and listening to classical music. Both Mr. Sanchez and Mrs. Sanchez like to cook.

  • Mr. Sanchez enjoys planting and growing vegetables.  
  • Mr. Sanchez does not like classical music.
  • Mrs. Sanchez cooks the vegetables that Mr. Sanchez grows.
  • Mrs. Sanchez enjoys reading nineteenth-century novels.
Answer: Mr. Sanchez enjoys planting and growing vegetables.


The total of the ages of Amar, Akbar, and Anthony is 80 years. What was the total of their ages three years ago? 

  • 71 years  
  • 72 years
  • 74 years
  • 77 years
Answer: 71 years


A pineapple costs Rs. 7 each. A watermelon costs Rs. 5 each. X spends Rs. 38 on these fruits. The number of pineapples purchased is

  • 2
  • 3
  • 4    
  • Data inadequate
Answer: 4


CMM, EOO, GQQ, _____, KUU

  • GRR
  • GSS
  • ISS     
  • ITT
Answer: ISS 


In the series 2, 6, 18, 54, ...... what will be the 8th term?

  • 4370
  • 4374    
  • 7443
  • 7434
Answer: 4374


589654237, 89654237, 8965423, 965423,?

  • 58965
  • 65423
  • 89654
  • 96542     
Answer: 96542


All the tulips in Zoe's garden are white. All the pansies in Zoe's garden are yellow. All the flowers in Zoe's garden are either white or yellow If the first two statements are true, the third statement is

  • True
  • False
  • uncertain    
Answer: uncertain


During the past year, Josh saw more movies than Stephen. Stephen saw fewer movies than Darren. Darren saw more movies than Josh. If the first two statements are true, the third statement is 

  • True
  • False
  • uncertain    
Answer: uncertain


Georgia is older than her cousin Marsha. Marsha's brother Bart is older than Georgia. When Marsha and Bart are visiting with Georgia, all three like to play a game of Monopoly. Marsha wins more often than Georgia does.

  • When he plays Monopoly with Marsha and Georgia, Bart often loses.
  • Of the three, Georgia is the oldest.
  • Georgia hates to lose at Monopoly.
  • Of the three, Marsha is the youngest.    
Answer: Of the three, Marsha is the youngest.


A is the son of C; C and Q are sisters; Z is the mother of Q and P is the son of Z. Which of the following statements is true?

  • P and A are cousins
  • P is the maternal uncle of A            
  • Q is the maternal grandfather of A
  • C and P are sisters
Answer: P is the maternal uncle of A 

Introducing Sonia, Aamir says, "She is the wife of only nephew of only brother of my mother." How Sonia is related to Aamir?

  • Wife     
  • Sister
  • Sister-in-law
  • Data is inadequate
Answer: Wife


FAG, GAF, HAI, IAH, ____ 

  • JAK       
  • HAL
  • HAK
  • JAI
Answer: JAK


Look at this series: 36, 34, 30, 28, 24, ... What number should come next?

  • 20
  • 22     
  • 23
  • 26
Answer: 22


Look at this series: 2, 1, (1/2), (1/4), ... What number should come next?

  • (1/3)
  • (1/8)    
  • (2/8)
  • (1/16)
Answer: (1/8)

Friday, April 26, 2019

How to Display Date and Time in JavaScript

In this JavaScript program, you will learn how to display date and time in JavaScript. Display date and time in your webpage in JavaScript program. 



//Display Date and Time in JavaScript
<!DOCTYPE html>
<html>
<body>

<h1>My First JavaScript</h1>

<button type="button"
onclick="document.getElementById('clock').innerHTML = Date()">
Click Here to Display Date and Time.</button>

<p id="clock"></p>

</body>
</html> 


The output of the program:

When you run this program in your browser, you can see that.

display date and time in javascript
Display Date and Time


When you click the option, Click Here to Display Date and Time, you can see that the default date and time in your computer.

display date and time in javascript
display date and time in javascript