[thelist] Accessing DOM-created form field values onsubmit

Andrew Clover and-evolt at doxdesk.com
Wed Mar 10 18:46:57 CST 2004


Alexis Molina <alexis.molina at gateway.com> wrote:

 > Everything DOM-wise seems to work beautifully, but when I submit the
 > form, I cannot retrieve the posted value for my DOM-created <SELECT>
 > from the server-side

Your code works for me in IE6, IE5, Firefox 0.8 and Opera 7.5.

I think there are *some* older browsers that might not understand:

 >    newSelect.setAttribute("name","sel_changed_by");

preferring the HTML-specific DOM attributes:

   newSelect.name= 'sel_changed_by';

but I wouldn't worry too much about that.

 > via: request("new_select_name")  <-- in my case, "selChangedBy"

Bzzt, should be 'sel_changed_by': it is the 'name' property of a form 
field that determines its name in the submission, not the 'id'. 'id' is 
not a special attribute, it's used the same as on any HTML element: to 
pick out an element for further scripting/styling attention. It may be a 
good idea to use the same string for 'name' and 'id' to avoid confusion 
when you do actually need to use an 'id'.

 > I read somewhere that the <SELECT> has to be appended directly to the

 > <FORM> element

Nah.

-- 
Andrew Clover
mailto:and at doxdesk.com
http://www.doxdesk.com/


More information about the thelist mailing list