Sunday, March 31, 2019

How to get the value of selected radio button in a group using jQuery

    $(document).ready(function(){
        $("input[type='button']").click(function(){
            var radioValue = $("input[name='gender']:checked").val();
            if(radioValue){
                alert("Your are a - " + radioValue);
            }
        });
       
    });

Allow Number to insert into text box

function isNumber(evt) {
    evt = (evt) ? evt : window.event;
    var charCode = (evt.which) ? evt.which : evt.keyCode;
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        return false;
    }
    return true;
}

onkeypress="return isNumber(event)"

Friday, March 29, 2019

How to: enable CORS in express.js (node.js)

Express.js is one of the most popular node.js frameworks for serving website or build APIs.

Steps to use CROS in node.js

1. npm install cors
2. Use the following code
   var express = require('express')
   var cors = require('cors')
   var app = express()

app.use(cors())

app.get('/userList', function (req, res, next) {
  res.json({msg: 'Enabled the CROS'})
})

app.listen(80, function () {
  console.log('Enabled CORS listening on port 80')
}) 

Friday, March 22, 2019

Saturday, March 16, 2019

How to Import and Export Databases


EXPORT
To Export a database, open up terminal, making sure that you are not logged into MySQL and type :

mysqldump -u [username] -p [database name] > [database name].sql

Import

source filepath.../filename.sql;