[thelist] Accessing DOM-created form field values onsubmit

Molina, Alexis alexis.molina at gateway.com
Wed Mar 10 12:08:58 CST 2004


Hello All:

I'm new to the list, and somewhat new to W3C DOM development, so 

Go easy on me.  What I'm trying to do is simple enough:

 

- I have a form with numerous form fields in it.

- One of the <SELECT>'s onchange attribute calls a client-side 

JavaScript function that builds a new <tr> between it and a submit 

button row using standard DOM methods [createElement(); setAttribute ();
insertBefore(); etc.]

- This new <TR> uses appendChild() to append a second <SELECT> created via
createElement()

- Another clientside JavaScript function validates the rules for this new
<TR> + <SELECT> row, then it submits to the server (ASP)

 

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 via: request("new_select_name")  <-- in my case, "selChangedBy"

 

A short synopsis of my JavaScript DOM function:

 

function insertTR()

{

   var newTR = document.createElement("tr");

   var newTD = document.createElement("td");

   var newSelect = document.createElement("select");

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

   newSelect.setAttribute("id","selChangedBy");

   var defaultOption = document.createElement("option");

   defaultOption.setAttribute("value","0");

   newSelect.appendChild(defaultOption);

   newTD.appendChild(newSelect);

   newTR.appendChild(newTD);

   

   var refTR = document.getElementById("saverow"); //this is the <TR> that
contains my submit button

   var tblElm = refTR.parentNode; //this is the <TABLE> that contains my
<TR>'s -- one of several tables conatined in the <FORM>

   tblElm.insertBefore(newTR,refTR);

}

 

Does anyone know what I'm doing incorrectly?  I read somewhere that the
<SELECT> has to be appended directly to the <FORM> element, instead of to a
child of the <FORM> element, but I'm not sure how I would do this precisely.
I would really appreciate any help you could offer.

 

Kind Regards,

 

Alexis Molina

San Diego, CA

 

 



More information about the thelist mailing list