Jump to content

Moving file value from one file element to another?


Ninjakreborn

Recommended Posts

Ok...strange issue. I have a multi-adding system.  It allows a user to input data then add similiar items. It is suppose to create the new form on a slider and moves the values from the old form to the new form. Nothing is submitted yet, it's all just in xhtml/css/javascript.  They can add as many as they want then submit them all at once. The only field I can't seem to pass is the file.

I want to be able to pass the photo from one form to the next.

var inputs = document.forms["itemAddMultipleForm"].elements;
for(var n = 0; n < inputs.length; n++)
{
	if(inputs[n].id.replace('item['+assetType+']['+fromItem+']', '') == inputs[n].id) continue;
	var fromElem = $(inputs[n].id);
	var toElem = inputs[n].id.replaceAll('item['+assetType+']['+fromItem+']', 'item['+assetType+']['+toItem+']');
	toElem = $(toElem);
	//for (x in fromElem) {
	//		alert(x);
	//}
	switch(fromElem.type)
	{
		case "hidden":
		case "textarea":
		case "text":
			toElem.value = fromElem.value;
			break;
		case "select-one":
			toElem.selectedIndex = fromElem.selectedIndex;
			break;
		case "checkbox":
			toElem.checked = fromElem.checked;
			break;
    	case "file":              
     		toElem.value = fromElem.value;
      	break;
	}

You can see were I added case "file" to try and do it..I tried moving value from the other to the new..and it's not working. Any

advice.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.