HTML defaultPrevented Event Property

Chandu yadav
Updated on 30-Jul-2019 22:30:26

171 Views

The defaultPrevented event property in HTML is used to check whether the preventDefault() method was called or not. It returns a boolean value i.e. true if the preventDefault() method was called, else false.Following is the syntax −event.defaultPreventedLet us now see an example to implement the defaultPrevented event property in HTML −Example Live Demo Demo Heading Demo (click me)    document.getElementById("myid").addEventListener("click", function(event){       event.preventDefault()       alert("Was preventDefault() called: " + event.defaultPrevented);    }); OutputClick on the link and the following would get displayed in the alert box −

Extract Area Codes from Phone Number with MySQL

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

1K+ Views

Let’s say we have a list of phone numbers and from that we want to get the area codes. These area codes are for example, the first 3 digits of the phone number. Use LEFT() function from MySQL for this.Let us first create a table −mysql> create table DemoTable -> ( -> AreaCodes varchar(100) -> ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command. Here, let’s say we have included the phone numbers −mysql> insert into DemoTable values('90387568976') ; Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('90389097878' ; ... Read More

Select Last Day of Current Year in MySQL

Ankith Reddy
Updated on 30-Jul-2019 22:30:26

1K+ Views

In order to get last day of current year, you can use LAST_DAY() from MySQL. The syntax is as follows−SELECT LAST_DAY(DATE_ADD(CURDATE(), INTERVAL 12-MONTH(CURDATE()) MONTH));Let us implement the above syntax to know the last day of current year−mysql> SELECT LAST_DAY(DATE_ADD(CURDATE(), INTERVAL 12-MONTH(CURDATE()) MONTH));This will produce the following output −+-------------------------------------------------------------------+ | LAST_DAY(DATE_ADD(CURDATE(), INTERVAL 12-MONTH(CURDATE()) MONTH)) | +-------------------------------------------------------------------+ | 2019-12-31 | +-------------------------------------------------------------------+ 1 row in set (0.00 sec)

Difference Between a Blockchain and a Database

Prasanna Kotamraju
Updated on 30-Jul-2019 22:30:26

262 Views

The difference between a Block chain and a traditional database begins with architecture, creation, access, and permissions. They differ in each and every aspect except that they both are huge repositories of data which is stored and accessed in an organised form, digitally.DatabaseThis runs on a client-server network, where there is a central repository of data that will be accessed by those nodes who have permission to access the data. The data of the database is maintained by administrators, and mostly nodes will have access to retrieve the data as per their requirement.Database, which is an electronic collection of data ... Read More

Create a Number Spinner in Java

Chandu yadav
Updated on 30-Jul-2019 22:30:26

417 Views

At first, create a SpinnerModel −SpinnerModel value = new SpinnerNumberModel(50, 0, 75, 1);Now, set the values −JSpinner spinner = new JSpinner(value);The following is an example to create a number spinner −Examplepackage my; import javax.swing.*; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame("Spinner Demo");       SpinnerModel value = new SpinnerNumberModel(50, 0, 75, 1);       JSpinner spinner = new JSpinner(value);       spinner.setBounds(50, 80, 70, 100);       frame.add(spinner);       frame.setSize(550,300);       frame.setLayout(null);       frame.setVisible(true);    } }This will produce the following output −

Filter by Several Array Elements in MongoDB

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

197 Views

For this, you can use $elemMatch operator. The $elemMatch operator matches documents that contain an array field with at least one element that matches all the specified query criteria. Let us first create a collection with documents −> db.filterBySeveralElementsDemo.insertOne(    "_id":100,    "StudentDetails": [       {          "StudentName": "John",          "StudentCountryName": "US",       },       {          "StudentName": "Carol",          "StudentCountryName": "UK"       }    ] } ); { "acknowledged" : true, "insertedId" : 100 } > db.filterBySeveralElementsDemo.insertOne(    { ... Read More

Best Data Type for Storing Large Strings in MySQL

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

916 Views

You can use text data type to store large strings. Following is the syntax −CREATE TABLE yourTableName (    yourColumnName text,    .    .    N );Let us first create a table −mysql> create table DemoTable -> ( -> MyStringValue text -> ); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('This is a text data type to store large string'); Query OK, 1 row affected (0.17 sec)Display all records from the table using select statement −mysql> select *from ... Read More

Average of First N Even Natural Numbers

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

1K+ Views

Average or mean of n even natural number is the sum of numbers divided by the numbers.You can calculate this by two methods &minusFind the sum of n even natural numbers and divide it by number, Using loop.Find the sum of n even natural numbers and divide it by number, Using formula.Method 1 - Using LoopFind the sum of even natural numbers using a loop that counts up to the number we want the sum. Then we will divide it by n.Example Code Live Demo#include int main(void) {    int n = 5;    int sum = 0;    int ... Read More

Find Second Smallest of N Elements with Given Complexity Constraint in C++

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

141 Views

This is a C++ program to find Second Smallest of n elements with given complexity constraint.AlgorithmBegin    function SecondSmallest() :       /* Arguments to this function are:          A pointer array a.          Number of elements n       */    // Body of the function:       A variable s1 is declared as to keep track of smallest number.       A variable s2 is declared as to keep track of second smallest number.       Initialize both s1 and s2 with INT_MAX.       Traverse ... Read More

Get Database Major Version in Java

Arushi
Updated on 30-Jul-2019 22:30:26

306 Views

The getDatabaseMajorVersion() method of the DatabaseMetaData interface returns the major version of the underlying database in integer format.To get major version of the underlying database −Make sure your database is up and running.Register the driver using the registerDriver() method of the DriverManager class. Pass an object of the driver class corresponding to the underlying database.Get the connection object using the getConnection() method of the DriverManager class. Pass the URL the database and, user name, password of a user in the database, as String variables.Get the DatabaseMetaData object with respect to the current connection using the getMetaData() method of the Connection ... Read More

Advertisements