Wednesday, June 2, 2021

Slip 10. Write a jQuery code to make first word of each statement to bold.

 

Slip 10. Write a jQuery code to make first word of each statement to bold. 

<!DOCTYPE html>
<html>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  
  <body>
    <p>Computer Application</p>
    <p>Autocad</p>
    <p>Data Structure using c</p>
    <p>Software Testing</p>
    <p>Java Programming</p>
  <script>
     $(document).ready(function(){
       $('p').each(function(){  
          var pdata = $(this);  
          pdata.html(pdata.text().replace(/(^\w+)/,'<strong>$1</strong>'));  
        }); 
     });
   </script>
  </body>
 </html>






Tuesday, June 1, 2021

Slip 9. Write a jQuery code to allow the user to enter only 15 characters into the textbox.

 

9. Write a jQuery code to allow the user to enter only 15 characters into the textbox. 

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  
  <title>Limit character input in the textarea including count</title>
 <style type="text/css">
  textarea {
       display:block;
       margin:1em 0;
 }  
</style>  
 
 <script>
     $(document).ready(function(){
    $('textarea').keyup(function() {
    var maxLength = 15;
    var textlen =  $('textarea').val().length;
    var remtextlen= maxLength-textlen
    $('#remchars').html(remtextlen);
});
});
 </script>
  </head>
 <body>
<form>
<label>Maximum 15 characters</label>
 
  <textarea id="textarea" maxlength="15"></textarea>
  <span id="remchars">15</span> Character(s) Remaining
 </form>
</body>
</html>

// OutPut




Slip 8. Write a jQuery code to print a page

 8. Write a jQuery code to print a page

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
   <title>Print a page using jQuery</title>
<script>
  $('btn.printPage').click(function(){
           window.print();
          return false;
});
 </script>
 <p>Click the button to print the current page.</p>
 <button onclick="window.print()">Print this page</button>
</head>
<body>
</body>
</html>

//Output






Slip 7. Write a jQuery code to create a zebra stripes table effect.

Slip 7 Write a jQuery code to create a zebra stripes table effect. 


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
 <style type="text/css">.table_style {
width: 500px;
margin: 0px auto;
      }

        table{
   width: 100%;
   border-collapse: collapse;
}

        table tr td{
    width: 50%;
    border: 2px solid 
                     #4d4dff;
    padding: 5px;
}
table tr th{
    border: 2px solid 
                    #4d4dff;
padding: 5px;
}
.zebra{
background-color:  
        #ff0001;
}
</style>
 <script>
 $(document).ready(function(){
$("tr:odd").addClass("zebra");
   });
 </script>
  <title>Create a Zebra Stripes table effect</title>
</head>
<body>
<div class="table_style">
<table>
<tr>
<th>Student Name</th>
<th>Marks in DBMS</th>
</tr>
<tr>
<td>Akshay</td>
<td>85.00</td>
</tr>
<tr>
<td>Sudhir</td>
<td>90.00</td>
</tr>
<tr>
<td>Kirti</td>
<td>75.00</td>
</tr>
<tr>
<td>Manasi</td>
<td>90.00</td>
</tr>
</table>
</div>
</body>
</html>


//Output








Friday, May 28, 2021

Slip 6. Write a jQuery code to blink text continuously.

 


//slip6.html

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  
  <title>Blink text using jQuery</title>
</head>
 <body>
  <p>I like <span class="blink">Cake</span> and <span class="blink">Ice-cream</span></p>
</body> 
 
  <style>
   p{ color:red}
   body{background-color:aqua}
  </style>
 <script>
  function blink_text() {
    $('.blink').fadeOut(500);
    $('.blink').fadeIn(500);
   }
  setInterval(blink_text, 1500);
 </script>
</html>

Slip 4 . Write a jQuery code to disable the submit button until the visitor has clicked a check box.


//slip4.html

 <!DOCTYPE html>
<html>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
      <meta charset="utf-8">
      <title>Disable/enable the form submit button</title>
   </head>
 <body>
   <input id="accept" name="accept" type="checkbox" value="y"/>Upload File<br>  
   <input id="submitbutton" disabled="disabled" name="Submit" type="submit" value="Submit" />
 </body>
 <script>
  $('#accept').click(function() {
if ($('#submitbutton').is(':disabled')) {
    $('#submitbutton').removeAttr('disabled');
    } else {
    $('#submitbutton').attr('disabled', 'disabled');
    }
  });
 </script>
  </html>

Slip 3. Write a jQuery code to disable right click menu in html page.


 3. Write a jQuery code to disable right click menu in html page.

//slip3.html

 <!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  
  <title>Disable right click menu in html page using jquery</title>
</head>
<script>
  $(document).bind("contextmenu",function(e){
  return false;
    });
 </script>
<body>
  <h1>If you click on this page<u> right click menu</u> will not be visible</h1>
</body>
</html>


Run slip3.html file on browser

//file:///C:/jquery/slip3.html

JQuery Solution


JQuery 

 1. Write a jQuery code to check whether jQuery is loaded or not.

2. Write a jQuery code to scroll web page from top to bottom and vice versa.

 3. Write a jQuery code to disable right click menu in html page.

 4. Write a jQuery code to disable the submit button until the visitor has clicked a check box. 

5. Write a jQuery code to fix broken images automatically. 

6. Write a jQuery code to blink text continuously. 

7. Write a jQuery code to create a zebra stripes table effect. 

8. Write a jQuery code to print a page. 

9. Write a jQuery code to allow the user to enter only 15 characters into the textbox. 

10. Write a jQuery code to make first word of each statement to bold. 

11. Write a jQuery code to create a division (div tag) using jQuery with style tag. 

12. Write a jQuery code to select values from a JSON object. 

13. Write a jQuery code to add list elements within an unordered list element. 

14. Write a jQuery code to remove all the options of a select box and then add one option and select it. 

15. Write a jQuery code to underline all the words of a text.

 16. Write a jQuery code to demonstrate how to get the value of a textbox. 

17. Write a jQuery code to remove all CSS classes from an application.

 18. Write a jQuery code to distinguish between left and right mouse click. 

19. Write a jQuery code to check if an object is a jQuery object or not. 

20. Write a jQuery code to detect whether the user has pressed 'Enter key' or not. 

21. Write a jQuery code to count number of rows and columns in a table.

 22. Write a jQuery code to display form data onto the browser. 

23. Write a jQuery code to find absolute position of an element. 

24. Write a jQuery code to remove a specific value from an array. 

25. Write a jQuery code to change button text. 

26. Write a jQuery code to add options to a drop-down list. 

27. Write a jQuery code to set background-image to the page. 

28. Write a jQuery code to get the selected value and currently selected text of a dropdown box. 

29. Write a jQuery code to disable a link. 

30. Write a jQuery code to Restrict "number"-only input for textboxes including decimal points. 

31. Write a jQuery code to set value in input text.

Sunday, May 16, 2021

Node js slip 10a solution Create a Node.js Application to download jpg image from the Server.

 Slip 10

       a.  Create a Node.js Application to download jpg image from the Server.                                                                          [Marks 15]

 

// slip10a.js

const http=require('http')

const fs=require('fs')

  http.createServer((req,res)=>{

      const files=fs.createReadStream('Tulips.jpg')

 res.writeHead(200,{'Content-disposition':'attachment;filename:Tulips.jpg'})

files.pipe(res)

}).listen(5000)


console.log("Image is download");


/* Output*/

//first install http

C:\Users\NEW\nodex>npm i http

npm WARN nodex@1.0.0 No description

npm WARN nodex@1.0.0 No repository field.


+ http@0.0.1-security

added 1 package and audited 12 packages in 3.915s

found 0 vulnerabilities


C:\Users\NEW\nodex>node slip10a.js

Image is download

^C

//Open crome browser and type localhost:5000 on addressbar to see image is downloading




Saturday, May 15, 2021

C++ slip2 solution

slip 2

a) Write a C++ program to find volume of cylinder, cone and sphere. (Use function overloading). 


#include<iostream.h>

float vol(int,int);

float vol(float,int);

int vol(int);


int main()

 {

   int radius,height,height2 ;

   float radius1,radius2;

  clrscr();

   cout<<"Enter the radius and height of the cylinder :" ;

   cin>>radius>>height;

   cout<<Enter the radius and height of the Cone :  ";

   cin>>radius2>>height2;

   cout<<"Enter radius of sphere: ";

   cin>>radius1;

    cout<<"Volume of Cylinder is "<<vol(radius,height);

   cout<<"Volume of Cone is"<<vol(radius2,height2);

   cout<<"Volume of Sphere is "<<vol(radius1);

   getch();

   return 0;

}


float vol(int radius , int height)

  {

   return(3.14 * radius* radius* height);

}


 int vol(float radius2, int height2)

  { 

    return(0.33*3.14 *radius2*radius2*height2);

}

int vol(int radius1)

{

  return((4*3.14 *radius1*radius1*radius1)/3);

}

Friday, May 14, 2021

Node js Slip 30 b Solution Create a Node.js file that demonstrat e create database and Hospital table (hReg, hName, address, contact) in M ySQL

 Slip 30 b

b) Create a Node.js file that demonstrat e create database and Hospital tabl(hReg, hName, address, contact) in M ySQL.



/* Hospital.js*/


var mysql=require('mysql');


var cn=mysql.createConnection({


host:"localhost",


user:"root",


password:"",


database:"mydb"


});



cn.connect(function(err){


      if(err) throw err;

  

      console.log("connected!");


      var sql="CREATE TABLE Hospital(hReg INT


       AUTO_INCREMENT PRIMARY KEY ,hName


        VARCHAR(20),hAddress VARCHAR(20),contact

 

          INT)";


  

    cn.query(sql,function(err,result){


       if(err)throw err;

 

            console.log("Table Created!");


   });


});



/* output*/



C:\Users\NEW\nodex>npm install mysql




C:\Users\NEW\nodex>node Hospital.js


connected!


Table Created!


Thursday, May 13, 2021

Node js Slip 6b Solution

 

a)     b.  Create a Node.js file that Insert Multiple Records in "student" table, and display the result object on console.        [Marks 25)


//student.js 

var mysql=require('mysql');

var cn=mysql.createConnection({

host:"localhost",

user:"root",

password:"",

database:"mydb"

});

cn.connect(function(err){

if(err) throw err;

var records=[

            ['Nishant',60],

            ['Akshay',80]

          ];

   console.log("connected!");

   var sql="INSERT INTO student(sname,percentage)VALUES?";

   cn.query(sql,[records],function(err,result){

         if(err)throw err;

           console.log(result);

           console.log("Number of records inserted: "+result.affectedRows); 

              });

});


/* Output


C:\Users\NEW\nodex>node student.js

connected!

OkPacket {

  fieldCount: 0,

  affectedRows: 2,

  insertId: 0,

  serverStatus: 2,

  warningCount: 0,

  message: '&Records: 2  Duplicates: 0  Warnings: 0',

  protocol41: true,

  changedRows: 0

}

Number of records inserted: 2

 

Wednesday, May 12, 2021

Node js Slip 5b Solution

 

 Slip 5 b

     b. Create a N ode.js file that Select all records from the "customers" table, and delete the specified record.


var mysql=require('mysql');

var cn=mysql.createConnection({

host:"localhost",

user:"root",

password:"",

database:"mydb"

});


cn.connect(function(err){

if(err) throw err;

console.log("connected!");

var sql="SELECT * from customer"

cn.query(sql,function(err,result){

if(err)throw err;

  console.log(result);

});

 var sql1 = "DELETE FROM customer WHERE caddress ='Pune'";

cn.query(sql1, function (err, result) {

    if (err) throw err;

    console.log("Number of records deleted: " + result.affectedRows);

  });

})


/* Output*/

C:\Users\NEW\nodex>node custtable.js

connected!

[

  RowDataPacket { cno: 1, cname: 'Ram', caddress: 'Pune' },

  RowDataPacket { cno: 2, cname: 'Kshitij', caddress: 'Pimpri' }

]

Number of records deleted: 1

^C

C:\Users\NEW\nodex>node custtable.js

connected!

[ RowDataPacket { cno: 2, cname: 'Kshitij', caddress: 'Pimpri' } ]

Number of records deleted: 0

^C

Node Slip1 B solution

 

Slip 1 b


b.   Create a Node.js file that demonstrate create database student DB and student table (Rno, Sname, Percentage) in MYSQL                                                                                                            [Marks 25]



/* tabledemo.js


var mysql=require('mysql');


var cn=mysql.createConnection({


host:"localhost",


user:"root",


password:"",


database:"student"


});



cn.connect(function(err){


if(err) throw err;


console.log("connected!");


var sql="CREATE TABLE student(rno INT


 AUTO_INCREMENT PRIMARY KEY ,sname


 VARCHAR(20),percentage INT)";


cn.query(sql,function(err,result){


if(err)throw err;


  console.log("Table Created!");


});


})



/* output*/



C:\Users\NEW\nodex>npm install mysql




C:\Users\NEW\nodex>node tabledemo.js


connected!


Table Created!


Tuesday, May 11, 2021

Node Slip3 Solution

 Slip 3 

Create  a  Node.js  Application  that  uses  user  defined  module circle.js which  exports  the functions area () and circumference () and display the details on console.

// circle.js

var PI = Math.PI;
 
exports.area = function (r) {
  return PI * r * r;
};
 
exports.circumference = function (r) {
  return 2 * PI * r;
};


//areacircle.js

var circle = require('./circle.js');

console.log( 'The area of a circle of radius 3 is ' + circle.area(3));

console.log( 'The circumference of a circle of radius 3 is '

      + circle.circumference(3));


/* Output*/


C:\Users\NEW\nodex>node areacircle.js

The area of a circle of radius 3 is 28.274333882308138

The circumference of a circle of radius 3 is 18.84955592153876





Adv. Java Slip 4 Solution

Slip 4

 /*Write a java program to display “Hello Java” message n times on the screen. (Use Runnable Interface).   */

import java.io.*;

class Hellojava implements Runnable

{

     Thread t;

     public Hellojava(String title)

       {

         t=new Thread(this,title);

         t.start();

       }

       public void run()

        {

          for(int i=0;i<20;i++)

         {

          System.out.println((i+1)+"ThreadName:"+Thread.currentThread().getName());

          try

            {

              Thread.sleep(10000);

            }

  catch(Exception e)

         {

             }

           }

         }

            }

  

 public class Demotext

   {

     public static void main(String args[])

       {

        System.out.println("ThreadName  :  "  +Thread.currentThread().getName());

        Hellojava t1=new Hellojava("HELLO JAVA");

      }

    }

/* Output*/
D:\JavaP>javac Demotext.java

D:\JavaP>java Demotext
ThreadName  :  main
1ThreadName:HELLO JAVA
2ThreadName:HELLO JAVA
3ThreadName:HELLO JAVA
4ThreadName:HELLO JAVA
5ThreadName:HELLO JAVA
6ThreadName:HELLO JAVA
7ThreadName:HELLO JAVA
8ThreadName:HELLO JAVA
9ThreadName:HELLO JAVA
10ThreadName:HELLO JAVA
11ThreadName:HELLO JAVA
12ThreadName:HELLO JAVA
13ThreadName:HELLO JAVA
14ThreadName:HELLO JAVA
15ThreadName:HELLO JAVA
16ThreadName:HELLO JAVA
17ThreadName:HELLO JAVA
18ThreadName:HELLO JAVA
19ThreadName:HELLO JAVA
20ThreadName:HELLO JAVA

Slip 10. Write a jQuery code to make first word of each statement to bold.

  Slip 10. Write a jQuery code to make first word of each statement to bold.  <!DOCTYPE html> <html>   <head>     <scri...