radhakrishna

radhakrishna

62 Articles Published

Articles by radhakrishna

Page 5 of 7

What is onkeypress event in JavaScript?

radhakrishna
radhakrishna
Updated on 19-Jun-2020 433 Views

The onkeypress event triggers when a key is pressed and released. You can try to run the following code to learn how to work with onkeypress event in JavaScript −Example                                            

Read More

How to set cookies expiry date in JavaScript?

radhakrishna
radhakrishna
Updated on 16-Jun-2020 6K+ Views

Extend the life of a cookie beyond the current browser session by setting an expiration date and saving the expiry date within the cookie. This can be done by setting the ‘expires’ attribute to a date and time.ExampleYou can try to run the following example to set the expiry date of a cookie by 1 Month −                                                  Enter name:                    

Read More

How can I convert Python dictionary to JavaScript hash table?

radhakrishna
radhakrishna
Updated on 05-Mar-2020 1K+ Views

Python and javascript both have different representations for a dictionary. So you need an intermediate representation in order to pass data between them. The most commonly used intermediate representation is JSON, which is a simple lightweight data-interchange format.The dumps function converts the dict to a string. exampleimport json my_dict = {    'foo': 42, 'bar': {       'baz': "Hello", 'poo': 124.2    } } my_json = json.dumps(my_dict) print(my_json)OutputThis will give the output −'{"foo": 42, "bar": {"baz": "Hello", "poo": 124.2}}'exampleThe load's function converts the string back to a dict. import json my_str = '{"foo": 42, "bar": {"baz": "Hello", "poo": 124.2}}' my_dict ...

Read More

How to save HTML Canvas as an Image with canvas.toDataURL()?

radhakrishna
radhakrishna
Updated on 04-Mar-2020 1K+ Views

Use toDataURL() method to get the image data URL of the canvas. It converts the drawing (canvas) into a64 bit encoded PNG URL.ExampleYou can try to run the following code to save the canvas as an image −                                  var canvas = document.getElementById('newCanvas');          var ctx = canvas.getContext('2d');          // draw any shape          ctx.beginPath();          ctx.moveTo(120, 50);          ctx.bezierCurveTo(130,100, 130, 250, 330, 150);          ctx.bezierCurveTo(350,180, 320, 180, 240, 150);          ctx.bezierCurveTo(320,150, 420, 120, 390, 100);          ctx.bezierCurveTo(130,40, 370, 30, 240, 50);          ctx.bezierCurveTo(220,7, 350, 20, 150, 50);          ctx.bezierCurveTo(250,5, 150, 20, 170, 80);          ctx.closePath();          ctx.lineWidth = 3;          ctx.fillStyle ='#F1F1F1';          ctx.fill();          ctx.stroke();          var dataURL =canvas.toDataURL();          

Read More

How do we include the legal number intervals for an input field in HTML?

radhakrishna
radhakrishna
Updated on 03-Mar-2020 350 Views

Use the step attribute to include the legal number intervals for an input field in HTML. The HTML input type step attribute sets the legal number intervals. Steps are number steps like 0, 5, 10, 15, 20, etc. The step attribute can be used together with the max and min attributes to create a range of legal values.ExampleYou can try to run the following code to implement step attribute −           HTML input step attribute                                            

Read More

Execute a script when a mouse button is released over an element in HTML?

radhakrishna
radhakrishna
Updated on 03-Mar-2020 271 Views

When the mouse button is released over an element, the onmouseup event triggers. You can try to run the following code to implement onmouseup attribute −Example                    This is demo heading.             Click above and then release.                function mouseDown() {             document.getElementById("myid").style.color = "yellow";          }          function mouseUp() {             document.getElementById("myid").style.color = "blue";          }          

Read More

How can we import data from .txt file into MySQL table?

radhakrishna
radhakrishna
Updated on 04-Feb-2020 4K+ Views

It can be done with the help of LOAD DATA INFILE statement. To illustrate the concept we are having the following data, separated by tab, in ‘A.txt’ whose path is d:/A.txt −100 John  USA 10000 101 Paul  UK  12000 102 Henry NZ  11000 103 Rick  USA 17000 104 Corey USA 15000We want to load the data of A.txt into the following table named employee_tbl −mysql> Create table employee_tbl(Id Int, Name varchar(20), Country Varchar(20), Salary Int); Query OK, 0 rows affected (0.91 sec)Now, the transfer of data from a file to a database table can be done with the help ...

Read More

Usage of white-space property in CSS

radhakrishna
radhakrishna
Updated on 31-Jan-2020 91 Views

The white-space property is used to control the flow and formatting of text.ExampleYou can try to run the following code to implement white-space property:                            This text has a line break and the white-space pre setting tells the browser to honor          it just like the HTML pre tag.    

Read More

Set the font style with CSS

radhakrishna
radhakrishna
Updated on 30-Jan-2020 205 Views

To set the font style, use the font-style property. Set the font to italic, normal and oblique.ExampleYou can try to run the following code to set the font-style to italic with CSS:                            Europe, Australia, South America are continents.          

Read More

Universal Selectors in CSS

radhakrishna
radhakrishna
Updated on 30-Jan-2020 750 Views

A selector is an HTML tag at which a style will be applied. This could be any tag like or etc.With the type selector, set for HTML tags like h1, h2, h3, p, etc:h2 {    color: #FFFF00; }Rather than selecting elements of a specific type, the universal selector simply matches the name of any element type:* {    color: #FFFF00; }

Read More
Showing 41–50 of 62 articles
« Prev 1 3 4 5 6 7 Next »
Advertisements