Click here to Skip to main content
15,891,607 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: combo box values not working for quote calculator Pin
Matt Harville28-Nov-13 23:03
Matt Harville28-Nov-13 23:03 
GeneralRe: combo box values not working for quote calculator Pin
Richard MacCutchan28-Nov-13 23:27
mveRichard MacCutchan28-Nov-13 23:27 
GeneralRe: combo box values not working for quote calculator Pin
Graham Breach29-Nov-13 3:06
Graham Breach29-Nov-13 3:06 
Questionhow to connect oracle database using jsp Pin
maheshkadtan28-Nov-13 8:14
maheshkadtan28-Nov-13 8:14 
SuggestionRe: how to connect oracle database using jsp Pin
Richard Deeming28-Nov-13 8:46
mveRichard Deeming28-Nov-13 8:46 
AnswerRe: how to connect oracle database using jsp Pin
Richard MacCutchan28-Nov-13 22:53
mveRichard MacCutchan28-Nov-13 22:53 
QuestionXMLHttpRequest (a)synchronous file upload Pin
csrss26-Nov-13 19:41
csrss26-Nov-13 19:41 
AnswerRe: XMLHttpRequest (a)synchronous file upload Pin
csrss26-Nov-13 21:17
csrss26-Nov-13 21:17 
Responding to my own question but it seems like I was messing around with this keyword in an inappropriate way. Correct code for sequential async file uploader goes like this:

JavaScript
function XMLHttpUploader(place, targetPHP)
{
	upload = function (currentArray, arrayTotalSize) {
	    var currentFile = currentArray.shift();
	    
	    if (currentFile) {
	        var xhr = new XMLHttpRequest();
	        xhr.open('POST', targetPHP, true);
	        xhr.setRequestHeader('UP-FILENAME', currentFile.name);
	        xhr.setRequestHeader('UP-SIZE', currentFile.size);
	        xhr.setRequestHeader('UP-TYPE', currentFile.type);
	        xhr.onreadystatechange = function () {
	            if (this.readyState == 4 && this.status == 200) {
	                var progressBar = document.querySelector('progress');
	                if (progressBar) {
	                    progressBar.value = Math.round(((arrayTotalSize - currentArray.length) * 100) / arrayTotalSize);
	                }

	                upload(currentArray, arrayTotalSize);
	            }
	        }
	        xhr.onerror = function () {
	            alert('File transfer failed!');
	        }
	        xhr.send(currentFile);
	    }
	    else {
	        var progressBar = document.querySelector('progress');
	        if (progressBar) {
	            progressBar.value = 100;
	            setTimeout("location.reload(true);", 2000);
	        }
	    }
	}

	// Function drop file
	this.drop = function(event) 
	{
	    event.preventDefault();
		var currentArray = new Array();
		for (var i = 0; i < event.dataTransfer.files.length; i++) {
		    currentArray.push(event.dataTransfer.files[i]);
		}
		upload(currentArray, currentArray.length);
	}
	
	// The inclusion of the event listeners (DragOver and drop)
	this.uploadPlace =  document.getElementById(place);
	this.uploadPlace.addEventListener("dragover", function(event)
	{
		event.stopPropagation(); 
		event.preventDefault();
	}, true);
	this.uploadPlace.addEventListener("drop", this.drop, false); 

}

011011010110000101100011011010000110100101101110
0110010101110011

Questiononkeypress event is not working google chrome Pin
Mithra Madhu25-Nov-13 20:36
Mithra Madhu25-Nov-13 20:36 
QuestionRe: onkeypress event is not working google chrome Pin
ZurdoDev6-Dec-13 10:28
professionalZurdoDev6-Dec-13 10:28 
Questionrestrict file type and size of form upload javascript only Pin
vbslacker24-Nov-13 8:37
vbslacker24-Nov-13 8:37 
AnswerRe: restrict file type and size of form upload javascript only Pin
Snehasish_Nandy24-Nov-13 20:06
professionalSnehasish_Nandy24-Nov-13 20:06 
AnswerRe: restrict file type and size of form upload javascript only Pin
abdul0425-Nov-13 23:53
abdul0425-Nov-13 23:53 
Question[Javascript] Find unused funtions and variables in Javascript using VS2010 Ultimate Pin
Member 1041144619-Nov-13 2:47
Member 1041144619-Nov-13 2:47 
AnswerRe: [Javascript] Find unused funtions and variables in Javascript using VS2010 Ultimate Pin
thatraja19-Nov-13 3:16
professionalthatraja19-Nov-13 3:16 
QuestionHaving a Problem with Return Value in Javascript Function Pin
Doug Pruiett12-Nov-13 16:25
Doug Pruiett12-Nov-13 16:25 
AnswerRe: Having a Problem with Return Value in Javascript Function Pin
Graham Breach12-Nov-13 22:44
Graham Breach12-Nov-13 22:44 
GeneralRe: Having a Problem with Return Value in Javascript Function Pin
Doug Pruiett13-Nov-13 3:30
Doug Pruiett13-Nov-13 3:30 
GeneralRe: Having a Problem with Return Value in Javascript Function Pin
Graham Breach13-Nov-13 5:27
Graham Breach13-Nov-13 5:27 
AnswerRe: Having a Problem with Return Value in Javascript Function Pin
Doug Pruiett13-Nov-13 4:19
Doug Pruiett13-Nov-13 4:19 
GeneralRe: Having a Problem with Return Value in Javascript Function Pin
Richard Deeming13-Nov-13 4:51
mveRichard Deeming13-Nov-13 4:51 
GeneralRe: Having a Problem with Return Value in Javascript Function Pin
Richard MacCutchan13-Nov-13 6:10
mveRichard MacCutchan13-Nov-13 6:10 
SuggestionRe: Having a Problem with Return Value in Javascript Function Pin
chxm199016-Nov-13 3:30
chxm199016-Nov-13 3:30 
QuestionShowing Questions Below Answers After The Submit Button Is Pressed? Pin
KeonD12311-Nov-13 10:25
KeonD12311-Nov-13 10:25 
AnswerRe: Showing Questions Below Answers After The Submit Button Is Pressed? Pin
twseitex12-Nov-13 3:19
twseitex12-Nov-13 3:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.