You are on page 1of 11

<html>

<body>

<form name="myform">

<input type="checkbox" name="a">Apple

<input type="checkbox" name="b">Banana

<input type="checkbox" name="c">Mango

<input type="checkbox" name="d">Orange

<input type="button" value="submit" onclick="fun()">

<input type="text" name="txt" >

</form>

</body>

<script>

with(document.forms.myform)

function fun()

var ab="You selected";

//var all=document.getElementById("txt");

if(a.checked==true)

txt.value+=ab+"Apple";

if(b.checked==true)

txt.value+=ab+"banana";

}
if(c.checked==true)

txt.value+=ab+"mango";

if(d.checked==true)

txt.value+=ab+"orange";

</script>

</html>

<html>

<body>

<select id="ch" onchange="fun(this.value)">

<option value="Mumbai">Mumbai</option>

<option value="Delhi">Delhi</option>

<option value="Bangaluru">Bangaluru</option>

</select>

<br>

<br>

<table border="2">

<tr>
<th>

City Name:

</th>

<th>

Discription:

</th>

<th>

Image:

</th>

</tr>

<tr>

<td>

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

</td>

<td>

<p id="des"></p>

</td>

<td>

<img src="" name="image">

</td>

</tr>

</table>

<script>

function fun(val){

document.getElementById("demo").innerHTML=val;

if(val=='Mumbai')

document.getElementById("des").innerHTML="This is mumbai";

document.image.src="orange.jpg"

if(val=='Delhi')
{

document.getElementById("des").innerHTML="This is delhi";

document.image.src="Mango.jpg"

if(val=='Bangaluru')

document.getElementById("des").innerHTML="This is Bangaluru";

document.image.src="apple.jpg"

</script>

</body>

</html>

<html>

<body id="bg">

<form name="myform">

<input type="button" value="Red" name="clk" onclick="fun(this.value)" >

</form>

</body>

<script>

with(document.forms.myform){

function fun(val)

if(val=="Red"){

clk.value="Blue"

document.getElementById("bg").style.background=val;
}

if(val=="Blue"){

clk.value="Red"

document.getElementById("bg").style.background=val;

// if(clk.value=="Red"){

// clk.value="Blue"

// //bg.style.background=val;

// }

// if(clk.value=="Blue"){

// clk.value="Red"

// }

</script>

</html>

<html>

<body>

<table border="2">

<tr>

<td>

<ul>

<li>

<a
onmouseover="javascript:document.getElementById('main').innerHTML='Discount is=80%'">

<h2>Mrutunjay</h2>
</a>

</li>

<li>

<a
onmouseover="javascript:document.getElementById('main').innerHTML='Discount is=70%'">

<h2>Mrutunjay</h2>

</a>

</li>

<li>

<a
onmouseover="javascript:document.getElementById('main').innerHTML='Discount is=60%'">

<h2>Mrutunjay</h2>

</a>

</li>

</ul>

</td>

<td>

<!-- <label name="main">Discount =</label> -->

<p id="main" >Discount is=</p>

</td>

</tr>

</table>

</body>

</html>

<html>

<body>

<table border="2">

<tr>

<td>
Name:

</td>

<td>

<input type="text" id="name" required>

</td>

</tr>

<tr>

<td>

Email:

</td>

<td>

<input type="text" id="email" required>

</td>

</tr>

<tr>

<td>

Pin code:

</td>

<td>

<input type="text" id="pin" required>

</td>

</tr>

<tr>

<td>

</td>

<td>

<button onclick="Validate()">Submit</button>

</td>

</tr>

</table>
<script>

function Validate(){

var regex=/^\d{6}$/;

var n=document.getElementById("name").value

var e=document.getElementById("email").value

var p=document.getElementById("pin").value

p=parseInt(p);

if(n.length==0 || e.length==0 || p.length==0 ){

alert("Field should not be blank")

else{

if(regex.test(p)){

alert("Form submitted successfully")

else{

alert("Pin digit should not contain any char")

</script>

</body>

</html>

<html>

<body>

Username:

<input type="text" id="user">

<br><br>
Password:

<input type="password" id="pass">

<br><br>

<input type="button" onclick="check()" value="Sumbit">

<script>

var arr=[['user1','pass1'],['user2','pass2'],['user3','pass3']];

function check()

var u=document.getElementById("user").value;

var p=document.getElementById("pass").value;

switch(u){

case arr[0][0]:

if(p==arr[0][1])

alert("Login")

else{

alert("login unsuccessfully");

break;

case arr[1][0]:

if(p==arr[1][1])

alert("Login")

else{

alert("login unsuccessfully");

break;

case arr[2][0]:

if(p==arr[2][1])

alert("Login")

else{

alert("login unsuccessfully");
}

break;

default:

alert("login unsuccessfully");

</script>

</body>

</html>

<html>

<body>

<script>

var arr=[1,4,3,2,1,4,2,1]

var uni=[...new Set(arr)]

var res=0;

for(var i=0;i<arr.length;i++){

for(var j=0;j<arr.length;j++){

if(i!==j){

if(uni[i]==arr[j]){

res+=1;

alert("count="+res)

</script>

</body>
</html>

You might also like