PDA

View Full Version : Free JavaSccript codes



JavaScriptBank
01-28-2011, 10:56 AM
Good and Nice JavaScripts

JavaScript Add More Unlimited Input Fields

The type of this JavaScript effect can be seen on many upload-allowance sites, such as Youtube, Flickr, ImageShack, Picasa, etc. That's your visitors can upload files through this JavaScript code, aft... detail (http://www.javascriptbank.com/javascript-add-more-unlimited-input-fields.html/en//) at JavaScriptBank.com - 2.000+ free JavaScript codes (http://www.javascriptbank.com/)


http://www.javascriptbank.com/javascript.images/form/javascript-add-more-unlimited-input-fields.jpg (http://www.javascriptbank.com/javascript/form/textarea/javascript-add-more-unlimited-input-fields/preview/en/)
Demo: JavaScript JavaScript Add More Unlimited Input Fields (http://www.javascriptbank.com/javascript-add-more-unlimited-input-fields.html/en/)


How to setup

Step 1: CSS below for styling thescript, place it into HEAD section
CSS

<style type="text/css">
/*
This script downloaded from www.JavaScriptBank.com
Come to view and download over 2000+ free javascript at www.JavaScriptBank.com
*/
#imageUpload input {
display: block;
}
</style>

Step 2: Copy & Paste JavaScript code below in your HEAD section
JavaScript

<script type="text/javascript">
// Created by: Jeroen Haan | http://www.haan.net
// This script downloaded from JavaScriptBank.com

function fileFields() {
var x = document.getElementById('imageUpload');
x.onclick = function() {
var i = parseFloat(this.lastChild.id)+1;
input = document.createElement("input");
input.setAttribute("type", "file");
input.setAttribute("name", 'imageName_' + i);
input.setAttribute("id", i);
this.appendChild(input);
}
}

// Multiple onload function created by: Simon Willison
// http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}

addLoadEvent(function() {
fileFields();
});
</script>

Step 3: Copy & Paste HTML code below in your BODY section
HTML

<a href="#" id="imageUpload"><input type="file" name="imageName_1" id="1" /></a>







Command to print web page in javascript (http://www.javascriptbank.com/window-print-method.html) - Javascript Time Picker (http://www.javascriptbank.com/time-picker-with-child-window.html) - JavaScript Go To URL Box (http://www.javascriptbank.com/go-to-url.html)


The Site may provide, or third parties may provide, links to non-JavaScriptBank.com Internet World Wide Web sites or resources. Because JavaScriptBank.com has no control over such sites and resources, you acknowledge and agree that JavaScriptBank.com is not responsible for the availability of such external sites or resources, and does not endorse and is not responsible or liable for any content, advertising, products, or other materials on or available from such sites or resources. You further acknowledge and agree that JavaScriptBank.com shall not be responsible or liable, directly or indirectly, for any damage or loss caused or alleged to be caused by or in connection with use of or reliance on any such content, goods or services available on or through any such site or resource.