Skip to content

Instantly share code, notes, and snippets.

View mazfreelance's full-sized avatar
🎯
Focusing

nimza mazfreelance

🎯
Focusing
View GitHub Profile
@mazfreelance
mazfreelance / JQUERY
Created August 22, 2017 07:27
Message box with location href
$.msgBox({
title: "Successfull !",
content: "Your job posting is being processed",
type: "right"
});
window.setTimeout(function () {
location.href = "index.php";
}, 3500);
@mazfreelance
mazfreelance / JQUERY: Check & Uncheck using selection
Last active August 24, 2017 03:27
JQUERY: Check & Uncheck using selection
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<SCRIPT language="javascript">
$(document).ready(function() {
$("#check").change(function() {
var d = $(this).val();
if(d == 'parent'){
$(".child").prop("checked", !d.checked);
}
});
@mazfreelance
mazfreelance / JQUERY: Check & Uncheck using selection
Last active August 24, 2017 03:48
JQUERY: Check & Uncheck using selection with database
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<SCRIPT language="javascript">
$(document).ready(function() {
//delete
$("#deletemessage").click(function() {
});
//check in database
@mazfreelance
mazfreelance / JQUERY: hide and show input type="text"
Last active August 24, 2017 03:49
JQUERY: hide and show input type="text"
<select name="oth" id="oth">
<option value="">Please Select</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
<input type="text" id="output" style="display: none"/>
$(document).ready(function(){
$("#oth").change(function() {
$(this).val() == "2" ? $('#output').show() : $('#output').hide();
@mazfreelance
mazfreelance / JQUERY: Check & Uncheck with single button
Last active August 24, 2017 09:59
JQUERY: Check/Uncheck with single button
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<SCRIPT language="javascript">
$(document).ready(function() {
$("#parent").click(function() {
var d = $(this).data();
$(".child").prop("checked", !d.checked);
// $('#parentnone').prop('checked', false);
//d.checked = !d.checked;
});
@mazfreelance
mazfreelance / PHP: calculate days between two date given
Last active December 20, 2017 07:26
PHP: calculate days between two date given (database & original)
//from php
$date1 = date_create('2017-10-10');
$date2 = date_create('2017-10-15');
$diff = date_diff($date1,$date2);
echo $diff->format("%R%a days"); // +14 days - %R is +/- | %a is number
//from database to php
$y = date('Y', strtotime($desc['gep_startdate']));
$m = date('n', strtotime($desc['gep_startdate']));
$date1 = date_create($desc['gep_startdate']);
@mazfreelance
mazfreelance / PHP: Listed date between two dates
Created December 20, 2017 07:27
PHP: Listed date between two dates
function getDatesFromRange($start, $end, $format = 'Y-m-d') {
$array = array();
$interval = new DateInterval('P1D');
$realEnd = new DateTime($end);
$realEnd->add($interval);
$period = new DatePeriod(new DateTime($start), $interval, $realEnd);
foreach($period as $date) {
@mazfreelance
mazfreelance / JQUERY checkbox validation
Created April 13, 2018 01:49
validation checkbox select atleast one
//html
<input type="checkbox" class="checkbox" name="checkbox[]" value="checkbox 1"/>
<input type="checkbox" class="checkbox" name="checkbox[]" value="checkbox 2"/>
<p id="validation"></p>
//form submit
$('#form-id').submit(function(evt){
evt.preventDefault();
...
if(!$('.checkbox').is(":checked")) {
@mazfreelance
mazfreelance / HTML+JS : Preview image
Last active April 13, 2018 01:51
JS: preview images before submit photo
//html
<div id="imagepicture"><i id="fafaimage" class="fa fa-picture-o" aria-hidden="true"></i></div>
<input type="file" accept="image/*" name="image_upload_file" id="image_upload_file" required/>
//js
function filePreview(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#imagepicture + img').remove();
@mazfreelance
mazfreelance / Dynamic List Laravel
Created September 6, 2018 03:15
Dynamic List Laravel
//Model
namespace App;
use Illuminate\Database\Eloquent\Model;
class ModelName extends Model
{
protected $table = 'table_name_dB';
}