Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Rucht  
#1 Posted : Monday, July 21, 2008 12:08:57 AM(UTC)
Rucht

Rank: Newbie

Groups: Member
Joined: 7/18/2008(UTC)
Posts: 6

Hello

I want to add some radio button in the multiple description exemple to add more description

I use addField method

my problem is when I get my post data the radio data is always the first one no metter what i have choose .

some code :
Code:

h += "<INPUT TYPE=\"RADIO\" name=\"MasterTag\" id=\"MasterTag" + uniqueId + "\" value =\"Screen Editeur\">Screen Editeur<br>"
h += "<INPUT TYPE=\"RADIO\" name=\"MasterTag\" id=\"MasterTag" + uniqueId + "\" value =\"Screenshot\">Screenshot<br>"

...

imageUploader1.AddField("MasterTag_" + index, document.getElementById("MasterTag" + div._uniqueId).value);




what I have to do to have the good result ?
Fedor  
#2 Posted : Monday, July 21, 2008 1:38:29 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,567

Thanks: 5 times
Was thanked: 64 time(s) in 63 post(s)
Could you post the entire page code?
Best regards,
Fedor Skvortsov
Rucht  
#3 Posted : Thursday, July 24, 2008 6:54:22 PM(UTC)
Rucht

Rank: Newbie

Groups: Member
Joined: 7/18/2008(UTC)
Posts: 6

Code:
var imageUploader1 = null;
var uniqueId = 0;
var prevUploadFileCount = 0;
var dragAndDropEnabled = true;


var allowDrag = false;

function fullPageLoad(){
	imageUploader1 = getImageUploader("ImageUploader1");

	var UploadPane=document.getElementById("UploadPane");
	
	while (UploadPane.childNodes.length > 0){
		UploadPane.removeChild(UploadPane.childNodes[0]);
	}

	//Fix Opera applet z-order bug
	if (__browser.isOpera){
		UploadPane.style.height = "auto";
		UploadPane.style.overflow = "visible";
	}


	//Handle drag & drop.
	if (__browser.isIE || __browser.isSafari){
		var target = __browser.isIE ? UploadPane : document.body;
		target.ondragenter = function(){
			var e=window.event;
			var data = e.dataTransfer;
			if (data.getData('Text')==null){
				this.ondragover();
				data.dropEffect="copy";
				allowDrag=true;
			}
			else{
				allowDrag=false;
			}
		}
		
		target.ondragover=function(){
			var e = window.event;
			e.returnValue = !allowDrag;
		}

		target.ondrop = function(){
			var e = window.event;
			this.ondragover();
			e.dataTransfer.dropEffect = "none";
			processDragDrop();
		}
	}
	else {
		window.captureEvents(Event.DRAGDROP);
		window.addEventListener("dragdrop", function(){
				processDragDrop();
			}, true);
	}

}

function processDragDrop(){
	alert("Adding files with drag & drop can not be implemented in standard version due security reasons. However it can be enabled in private-label version."+
		"\r\n\r\nFor more information please contact us at sales@aurigma.com");
	if (imageUploader1){
		//imageUploader1.AddToUploadList();
	}
}

//To identify items in upload list, GUID are used. However it would work 
//too slow if we use GUIDs directly. To increase performance, we will use 
//hash table which will map the guid to the index in upload list. 

//This function builds and returns the hash table which will be used for
//fast item search.
function getGuidIndexHash(){
	var uploadFileCount = imageUploader1.getUploadFileCount();
	var guidIndexHash = new Object();
	for (var i = 1; i <= uploadFileCount; i++){
		guidIndexHash["" + imageUploader1.getUploadFileGuid(i)] = i;
	}
	return guidIndexHash;
}

//This function returns HTML which represent the single item in the custom upload pane.
//It contains of the Thumbnail object and form elements for each piece of data (in our 
//case - title and description). If you want to upload extra data, you should write
//additional form elements here.
//
//It is highly recommended not to copy this function into the main HTML page to 
//avoid problems with activation of ActiveX controls in Internet Explorer with
//security update 912945. You can read more detailed about activation on Microsoft website:
//
//http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/overview/activating_activex.asp 
function addUploadFileHtml(index){
	var guid = "" + imageUploader1.getUploadFileGuid(index);
	var fileName = "" + imageUploader1.getUploadFileName(index);

	var h = "<table cellspacing=\"5\"><tbody>";
	h += "<tr>";
	h += "<td class=\"Thumbnail\" align=\"center\" valign=\"middle\">";

	//Add thumbnail control and link it with Image Uploader by its name and GUID.
	var tn = new ThumbnailWriter("Thumbnail" + uniqueId, 96, 96);
	//Copy codebase and version settings from ImageUploaderWriter instance.
	tn.activeXControlCodeBase = iu.activeXControlCodeBase;
	tn.activeXControlVersion = iu.activeXControlVersion;
	tn.javaAppletCodeBase = iu.javaAppletCodeBase;
	tn.javaAppletCached = iu.javaAppletCached;
	tn.javaAppletVersion = iu.javaAppletVersion;

	tn.addParam("ParentControlName", "ImageUploader1");
	tn.addParam("Guid", guid);
	tn.addParam("FileName", fileName);
	h += tn.getHtml();

	h += "</td>";
	h += "<td valign=\"top\">";
	
	//modif recuperation du nom du  fichier
	var nom = fileName.slice(fileName.lastIndexOf('\\')+1,fileName.lastIndexOf('.'));

	//Add Title element.
	h += "Titre:<br />";
	h += "<input id=\"Title" + uniqueId + "\" class=\"Title\" type=\"text\" value=\""+nom+"\"/><br />";
	
	//Ajout pour les MasterTag

	h += "<INPUT type=radio name=\"MasterTag\" id=\"MasterTag" + uniqueId + "\" value=\"Screenshot Officiel\">Screen Officiel";
	h += "<INPUT type=radio name=\"MasterTag\" id=\"MasterTag" + uniqueId + "\" value=\"Screenshot\">Screenshot";
	h += "<INPUT type=radio name=\"MasterTag\" id=\"MasterTag" + uniqueId + "\" value=\"Artwork\">Artwork";
	h += "<INPUT type=radio name=\"MasterTag\" id=\"MasterTag" + uniqueId + "\" value=\"Illustration\" checked>Illustration<br>";
	
			
	//Add Description element.
	h += "Tag:<br />";
	h += "<textarea id=\"Description" + uniqueId + "\" class=\"Description\"\"></textarea>";

	h += "</td>";
	h += "</tr>";
	h += "<tr>";
	h += "<td align=\"center\"><a href=\"#\" onclick=\"return Remove_click('" + guid + "');\">Remove</a></td>";
	h += "<td></td>";
	h += "</tr>";
	h += "</tbody></table>";

	//Create DIV element which will represent the upload list item.
	var div = document.createElement("div");
	div.className = "UploadFile";
	div.innerHTML = h;
	div._guid = guid;
	//_uniqueId is used for fast access to the Title and Description form elements.
	div._uniqueId = uniqueId;

	//Append this upload list item to the custom upload pane.
	document.getElementById("UploadPane").appendChild(div);

	//Increase the ID to guaranty uniqueness.
	uniqueId++;
}

//Synchronize custom upload pane with Image Uploader upload list when 
//some files are added or removed.
function ImageUploader_UploadFileCountChange(){
	if (imageUploader1){
		var uploadFileCount  = imageUploader1.getUploadFileCount();

		//Files are being added.
		if (prevUploadFileCount <= uploadFileCount){
			for (var i = prevUploadFileCount + 1; i <= uploadFileCount; i++){
				addUploadFileHtml(i);
			}
		}
		//Files are being removed.
		else{
			var guidIndexHash = getGuidIndexHash();
			var UploadPane = document.getElementById("UploadPane");
			var i = UploadPane.childNodes.length - 1;
			while (i >= 0){
				if (guidIndexHash["" + UploadPane.childNodes[i]._guid] == undefined){
					UploadPane.removeChild(UploadPane.childNodes[i]);
				}
				i--;
			}
		}

		prevUploadFileCount = uploadFileCount;

		document.getElementById("UploadButton").disabled = (uploadFileCount == 0);
	}
}

//Append the additional data entered by the user (title and description)
//to the upload. If you add more fields, do not forget to modify this event 
//handler to call AddField for these fields.
function ImageUploader_BeforeUpload(){
	var guidIndexHash = getGuidIndexHash();

	var UploadPane = document.getElementById("UploadPane");

	for (var i = 0; i < UploadPane.childNodes.length; i++){
		var div = UploadPane.childNodes[i];

		var index = guidIndexHash[div._guid];

		//Description will be sent as a native Description POST field 
		//provided by Image Uploader.
		imageUploader1.setUploadFileDescription(index,
			document.getElementById("Description" + div._uniqueId).value);

		//Title will be sent as a custom Title_N POST field, where N is an 
		//index of the file.
		imageUploader1.AddField("Title_" + index, document.getElementById("Title" + div._uniqueId).value);
		imageUploader1.AddField("MasterTag_" + index, document.getElementById("MasterTag" + div._uniqueId).value);
	}
}

//This function is used to handle Remove link click. It removes an item 
//from the custom upload pane by specified GUID.
function Remove_click(guid){
	var guidIndexHash = getGuidIndexHash();
	imageUploader1.UploadFileRemove(guidIndexHash[guid]);
}

//This function posts data on server.
function UploadButton_click(){
	imageUploader1.Send();
}

Edited by user Thursday, July 24, 2008 6:56:04 PM(UTC)  | Reason: Not specified

Fedor  
#4 Posted : Sunday, July 27, 2008 2:08:54 PM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,567

Thanks: 5 times
Was thanked: 64 time(s) in 63 post(s)
Quote:
my problem is when I get my post data the radio data is always the first one no metter what i have choose .


I see in your code:

Code:
    h += "<INPUT type=radio name=\"MasterTag\" id=\"MasterTag" + uniqueId + "\" value=\"Screenshot Officiel\">Screen Officiel";
    h += "<INPUT type=radio name=\"MasterTag\" id=\"MasterTag" + uniqueId + "\" value=\"Screenshot\">Screenshot";
    h += "<INPUT type=radio name=\"MasterTag\" id=\"MasterTag" + uniqueId + "\" value=\"Artwork\">Artwork";
    h += "<INPUT type=radio name=\"MasterTag\" id=\"MasterTag" + uniqueId + "\" value=\"Illustration\" checked>Illustration<br>";


You use the same ID value for 4 elements, at that time as ID value should be unique for each element.

Then in BeforeUpload event handler you add its value to upload data:

Code:
        imageUploader1.AddField("MasterTag_" + index, document.getElementById("MasterTag" + div._uniqueId).value);


In this case document.getElementById("MasterTag" + div._uniqueId) will always return first element.

To avoid this problem you can use the following code:

Code:
    h += "<INPUT type=radio name=\"MasterTag\" id=\"MasterTag" + uniqueId + "_1\" value=\"Screenshot Officiel\">Screen Officiel";
    h += "<INPUT type=radio name=\"MasterTag\" id=\"MasterTag" + uniqueId + "_2\" value=\"Screenshot\">Screenshot";
    h += "<INPUT type=radio name=\"MasterTag\" id=\"MasterTag" + uniqueId + "_3\" value=\"Artwork\">Artwork";
    h += "<INPUT type=radio name=\"MasterTag\" id=\"MasterTag" + uniqueId + "_4\" value=\"Illustration\" checked>Illustration<br>";


Thus all elements will have different IDs.

Then you can iterate through these 4 elements and add the selected value to upload data:

Code:
for (var z = 1;  z <= 4; z++){
    var mt = document.getElementById("MasterTag" + div._uniqueId + "_" + z);
    if (mt.checked){
        imageUploader1.AddField("MasterTag_" + index, mt.value);
        break;
    }
}


Please note, this code is untested.


Best regards,
Fedor Skvortsov
Rucht  
#5 Posted : Sunday, July 27, 2008 5:49:59 PM(UTC)
Rucht

Rank: Newbie

Groups: Member
Joined: 7/18/2008(UTC)
Posts: 6

It' s Working !!!

thanks you a lot !
Users browsing this topic
Similar Topics
Radio Buttons (Discussions – ActiveX/Java Uploader)
by karlito 3/14/2008 7:55:50 PM(UTC)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.