Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 793
Product
XFile
Version
all
Title
Posting multi-select form elements with XFile
Problem

In order to post form data with your upload using XFile, you must pick up the values from the HTML form using client-side script, and then pass them to the XFRequest object's AddFormElement method, like this:


XFile.AddFormElement("TextBox", document.getElementById('TextBox').value);
XFile.AddFormElement("DropDown",document.getElementById('DropDown').value );

But what about form elements that contain subcollections, such as multi-select lists or checkboxes?
Solution

The solution is to loop through the subcollection and call AddFormElement for each selected value:

var multi = document.getElementById('MultiSelect'); 
for ( var i = 0; i< multi.options.length; i++ ) 
{ 
if(multi.options[i].selected)
  {
   XFile.AddFormElement("MultiSelect",multi.options[i].value);
  }
}
Created : 3/15/2011 11:58:26 AM (last modified : 3/15/2011 11:58:26 AM)
Rate this article!
 
Comments