[Javascript] [SOLVED] JS Help: Dynamic form control

Troy III Ajnej trojani2000 at hotmail.com
Sun Mar 5 13:32:25 CST 2006


Sorry, I've just tested it. It doesn't work for me in either NN, FX nor IE.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Troy III
progressive art enterprise
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


>From: Michael Hulse <micky at ambiguism.com>
>Reply-To: "\[JavaScript List\]" <javascript at LaTech.edu>
>To: "\[JavaScript List\]" <javascript at LaTech.edu>
>Subject: Re: [Javascript] [SOLVED] JS Help: Dynamic form control
>Date: Sun, 5 Mar 2006 02:59:44 -0800
>
>  Actually, I just got it my code working by doing this:
>
><snip>
>
>var counter = 0;
>
>function moreFields() {
>    counter++;
>    var newFields = document.getElementById('readroot').cloneNode(true);
>    newFields.id = '';
>    newFields.style.display = 'block';
>    newFields.firstChild.nodeValue=counter + '. ';
>    changeId(newFields, counter);
>    var insertHere = document.getElementById('writeroot');
>    insertHere.parentNode.insertBefore(newFields,insertHere);
>}
>function delField() {
>    var writeroot = document.getElementById('writeroot');
>    if(counter >= 1) {
>        writeroot.parentNode.removeChild(writeroot.previousSibling);
>        counter--;
>    }
>}
>function changeId(r, c) {
>    var rKids = r.getElementsByTagName('*');
>    var i = rKids.length;
>    var rKid;
>    while(i--) {
>        rKid = rKids[i];
>        if (rKid.id) rKid.id = rKid.id + c;
>        if (rKid.name) rKid.name = rKid.name + c;
>    }
>}
>//setTimeout(moreFields, 100);
>/*window.onload = moreFields;*/
>event_attach('onload', moreFields);
>
></snip>
>
>XHTML:
>
><snip>
>
><div id="readroot" style="display: none">
>
>	<div class="fm-req">
>		<label for="item_">* Item name:</label>
>		<input name="item_" id="item" type="text" title="Item name" />
>	</div>
>
>	<div class="fm-req">
>		<label for="product_">* Product #:</label>
>		<input name="product_" id="product" type="text" title="Product number" />
>	</div>
>
>	<div class="fm-opt">
>		<label for="quantity_">Quantity desired:</label>
>		<input name="quantity_" id="quantity" type="text" title="Desired 
>quantity" />
>	</div>
>
>	<input class="fm-remove" id="remove" type="button" value="Remove Item" 
>onclick="delField();" />
>
>	<div class="horizRule"></div>
>
></div>
>
></snip>
>
>Above seems to work... not yet fully tested.
>
>Thanks again for help.
>Cheers,
>Micky


>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/




More information about the Javascript mailing list