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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.