[thelist] Accessing DOM-created form field values onsubmit

Mark Kennedy mark at eurogamer.net
Thu Mar 11 03:38:09 CST 2004


Hi there,

What browser are you testing this on?  It's possible that your browser isn't
respecting your additions when it comes to posting the form (who knows how
browsers organise their form data internally!).  I have to say your code looks
reasonable enough (although I don't have time to check it).  I can't find
references to this problem anywhere, except on www.quirksmode.org (follow links
'W3C DOM -> Tests -> Compatibility - Core') where the test for
appendChild() mentions reports of appending options to selects crashing IE 5.

If I were trying to achieve a similar effect, I would probably lump for just
hiding the 'dyanamic' field, using style="display: none" and then revealing it
with trObj.style.display = "table-row".  On IE, which I don't think supports
'table-row', you might have to try 'block'.  If you dropped the use of tables,
you could just use display: block on both browsers.

Hope that helps,

Mark


On Wed, 10 Mar 2004, Molina, Alexis wrote:

>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
>
> 
>
> 
>
>-- 
>* * Please support the community that supports you.  * *
>http://evolt.org/help_support_evolt/
>
>For unsubscribe and other options, including the Tip Harvester 
>and archives of thelist go to: http://lists.evolt.org 
>Workers of the Web, evolt ! 
>

 



More information about the thelist mailing list