Add new attribute to input field

Hi,

I need to use Javascript to add some new attributes to an inout field (see below).

Here is the standard input field:

<input id="uploader" type="file" auto="false" buttoncaption="Upload" multi="true" afterupload="link" maxsize="204800" />

Here’s how I need the input field to look (with the new attributes):

<input id="uploader" type="file" auto="false" buttoncaption="Upload" multi="true" afterupload="link" maxsize="204800" room_name="room" album_title="album" path="path" />

Is this possible?

Hi, I just tried this code but i’m not sure if it worked. The javascript should set those attributes and then the form gets posted after. However, when I look at the posted attributes, they didn’t seem to get set by the Javascript so I din’t think the code worked.

Any ideas?

var obj=document.getElementById('uploader');
var att = {"room_name":"room", "album_title":"album", "path":"path"};
for(var n in att) {
    obj.setAttribute(n, att[n]);
    }

Only name/value pairs, which you are not using, are submitted.

For a start, those aren’t standard attributes, so you should not be using them. But they aren’t getting “posted” because there is no reason to. The browser doesn’t post attributes. It’ll post the file and the name, and that’s it. That’s how forms work (whether GET or POST) - they supply name-value pairs of data.

If you want all that stuff to somehow get communicated to the server, you need to add a few <input type=“hidden”> elements, one for each name-value pair you want.

So how would I get the room_name, album_title and path values to be submitted?