Get value from select option and on change select option

To get value from select option field on any button click event use the syntax below ,

$(‘.btn-class’).click(function(){

var optVal= $("#selectID option:selected").val();

console.log(optVal);

});

To get value from select field on change option use the below code

$(“#select-field-id”).change(function() {
var line_item_unit= $(“#select-field-id:selected”).val();
console.log(line_item_unit);
});

 

Advertisements

Abstraction

It is a concept of hiding all information and give only the needful data to the user.

Abstraction will be having a class without implementation details , only the subclass use this abstraction methods and the implementations in done inside the subclass.

We can’t create the object for the abstract class , Abstract class cant be instantiated.

 

Swift Mailer SMTP configuration in Yii2

Swift Mailer libraries comes by default in yii2 application , so its very simple to configure and make use of it.

First we need to make configuration in config / web.php file

‘components’ => [
‘mailer’ => [
‘class’ => ‘yii\swiftmailer\Mailer’,
‘transport’ => [
‘class’ => ‘Swift_SmtpTransport’,
‘host’ => ‘smtp.gmail.com’,
‘username’ => ‘example@gmail.com’,
‘password’ => ‘examplepwd’,
‘port’ => ‘587’,
‘encryption’ => ‘tls’,
],
],
]

then in any controller you can use the function to send mail like below,

Yii::$app->mailer->compose()
->setFrom(‘example@gmail.com’)
->setTo(‘example@gmail.com’)
->setSubject(‘subject’)
->setTextBody(”)
->setHtmlBody(”)
->send();