|
Posted by Jeff North on 09/22/06 20:55
On Fri, 22 Sep 2006 20:15:59 +0000 (UTC), in comp.lang.php Brad
Everman <deathdog@otaku.freeshell.org>
<slrneh8h3o.1ht.deathdog@otaku.freeshell.org> wrote:
>|
>| I have an HTML form that passes arrays of values to PHP. Basically, each
>| row of the form tracks three separate values for processing. I have a JS
>| program that will dynamically add (or delete) rows to the form per the
>| user. The problem is that these values are not passed when the form is
>| submitted. If I hardcode the rows it works fine, so I know the processing
>| code isn't the problem. My question is how can I dynamically add form rows
>| via JS and have their values passed when the form is submitted? I
>| attempted something like $_POST["document.something"] but that did not
>| work.
>|
>| <SNIP>
>| <html>
>| <head>
>| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
>| <title>Add/Remove child: Javascript</title>
>| <script type="text/javascript">
>| <!--
>|
>| function addEvent()
>| {
>| var ni = document.getElementById('myDiv');
>| var numi = document.getElementById('theValue');
>| var num = (document.getElementById("theValue").value -1)+ 2;
>| //numi.value = num;
>| var divIdName = "my"+num+"Div";
>| var newdiv = document.createElement('div');
>| newdiv.setAttribute("id",divIdName);
>| newdiv.innerHTML = "Page Number: <input type=\"text\"
>| name=\"pageNumber[]\"><br /><br />Paragraph Number: <input type=\"text\"
>| name=\"paragraphNumber[]\"><br /><br />Instructions: <textarea
>| name=\"instruction[]\" rows=\"5\" cols=\"80\"></textarea><br /><input
>| type=submit value=\"Remove\"onclick=\"removeEvent(\'"+divIdName+"\')\"><br
>| /><br />";
>|
>| ni.appendChild(newdiv); }
>|
>| function removeEvent(divNum)
>| {
>| var d = document.getElementById('myDiv');
>| var olddiv = document.getElementById(divNum);
>| d.removeChild(olddiv);
>| }
>|
>| //-->
>| </script>
>| </head>
>|
>| <body>
>| <input type=submit value="Add Row" id="theValue"
>| onclick="addEvent();">
>| <div id="main">
>| <form>Page Number: <input type=\"text\"
>| name=\"pageNumber[]\"><br /><br />Paragraph Number: <input type=\"text\"
>| name=\"paragraphNumber[]\"><br /><br />Instructions: <textarea
>| name=\"instruction[]\" rows=\"5\" cols=\"80\"></textarea>
>|
>| <div id="myDiv"> </div>
>|
>| </form>
>|
>| </body>
>| </html>
>|
>| </SNIP>
This might help you out, watch the wordwrap:
http://groups.google.com.au/group/comp.lang.javascript/browse_thread/thread/f5213cbae40229cf/763da2d01aa2f896?lnk=gst&q=cross+browser+problem&rnum=1#763da2d01aa2f896
---------------------------------------------------------------
jnorthau@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Navigation:
[Reply to this message]
|