Q1. Write A Javascript Program That Greet User According To The Current Timing
Q1. Write A Javascript Program That Greet User According To The Current Timing
write a javascript program that greet user according to the current timing
<html>
<body>
<script type="text/javascript">
var d = new Date();
var time = d.getHours();
</body>
</html>
Q2.Describe the input tag and write the form element used in javascript?
Ans: The <input> tag specifies an input field where the user can enter data. <input> elements are used
within a <form> element to declare input controls that allow users to input data.
Name DECRIPTION
ANS: An alert box is often used if you want to make sure information comes through to the user. The
alert box takes the focus away from the current window, and forces the browser to read the message
Ex: Window.alert("Hello! world");// The alert() method displays an alert box with a
Ans.
<html>
<body>
<script >
document.body.bgColor="blue ";
</script>
</body>
</html>
Q5. Define the join mehod and explain with the example?
The join() method joins the elements of an array into a string, and returns the string.
The elements will be separated by a specified separator. The default separator is comma (,).
Ex:-
var fruits = ["Banana", "Orange", "Apple", "Mango"]; // array having names of fruit.
var energy = fruits.join(); // join method.
Banana,Orange,Apple,Mango // output.
Q6.form validation in javascript?
<html>
<body>
<p> id="p1"</p>
<script>
function validateForm() {
var username="saurav";
var password="ssb007"
var x = document.forms["name"].value;
var y= document.forms["pass"].value;
return false;
else
if(x!=username||y!=password)
else
</script></body></html>
Q7 Write a javascript code to zoom-in and zoom-out the image?
<script type="text/javascript">
} else{
myImg.style.width = (currWidth + 50) + "px"; // increase the width of image by 50 px each time
} else{
myImg.style.width = (currWidth - 50) + "px"; increase the width of image by 50 px each time
</script>
Q7. What is various type of datatype in javascript.
Ans:
@ Primitive data-type:
1.Boolean.
2.NULL.
3.Undefined.
Ans.
1. If and if..else
2. For
3. Switch
4. With:
with( Math ) {
x = round( LN2 + E + pow( y, 4 ) );
}
Note that the 'with' statement brings extra variable names into the
current scope. In the example above, if I already had a variable called
pow before the 'with' statement, this variable(y) would be unavailable
inside the with statement, as it would have been replaced by the method of
the Math object (as would any other variables that matched property or
method names). Once the 'with' statement is complete, the old variables
would become available again.