Skip to content

Instantly share code, notes, and snippets.

View w3villa's full-sized avatar

W3villa Technologies w3villa

View GitHub Profile
@w3villa
w3villa / DateRangePicker.js
Created March 3, 2014 09:32
JQuery UI date range picker
var DateRangePicker = function() {
this.init();
}
DateRangePicker.prototype = {
init: function() {
var today = new Date();
this.end_date = new Date(today.setDate(today.getDate() - 1));
this.start_date = new Date(today.setDate(today.getDate() - 7));
this.setDatePickerDefaults();
@w3villa
w3villa / formdata-file-uploader-form.html
Created November 20, 2013 11:21
Uploading files/image with Ajax & Jquery, without submitting a form. Read complete blog post at http://blog.w3villa.com/websites/uploading-filesimage-with-ajax-jquery-without-submitting-a-form/
<input id="avatar" type="file" name="avatar" />
<button id="upload" value="Upload" />
@w3villa
w3villa / iframe-file-uploader-form.html.erb
Last active December 28, 2015 20:59
Upload image without submitting form, works on all browsers. Read the complete blog post at http://blog.w3villa.com/programming/upload-image-without-submitting-form-works-on-all-browsers/
<!-- Change the target of the form to the hidden iframe -->
<form id="avatar_form" action="/welcome/upload" method="post" enctype="multipart/form-data" target="uploader_iframe">
<input id="avatar" type="file" name="avatar" size="30" />
</form>
<!-- Hidden iframe which will interact with the server, do not forget to give both name and id values same -->
<iframe id="uploader_iframe" name="uploader_iframe" style="display: none;"></iframe>
<!-- Just added to show the preview when the image is uploaded. -->
<img id="preview" src="preview.png" />