Passing on Javascript array data to a PHP-array
-
I found and adapted an HTML script as shown below. It fits my needs perfectly. However, I don't know how to store the field-values of repeated lines in a javascript array that subsequently passes its contents on to a PHP-array that enables me to store the date in a MYSQL-database. I tried to fix something myself in de 3rd codeblock of de AddRow()function. A second problem is: when de line is repeated I need to reset de field values to default. Does anybody have the knowledge that I so obviously do not have? ====================================================================== function AddRow () { var o_id = document.getElementById ("id").cloneNode(true); var label_id = document.getElementById ("label_id").cloneNode(true); var o_item = document.getElementById ("item").cloneNode(true); var o_subitem = document.getElementById ("subitem").cloneNode(true); var label_opm = document.getElementById ("label_opm").cloneNode(true); var o_opm = document.getElementById ('opm').cloneNode(true); // reset field opm document.getElementById("opm").innerHTML=""; o_id.name='id[]'; o_item.name = 'item[]'; o_subitem.name = 'subitem[]'; o_opm.name = 'opm[]'; var o_button = document.createElement ("input"); o_button.type = "button"; o_button.value = "Remove"; o_button.onclick = RemoveRow; var o_td_id = document.createElement ("td"); var o_td_item = document.createElement ("td"); var o_td_subitem = document.createElement ("td"); var o_td_opm = document.createElement ("td"); var o_td_button = document.createElement ("td"); var o_tr = document.createElement ("tr"); var o_body = document.getElementById ("dynamic_table_body"); o_td_id.appendChild (label_id); o_td_id.appendChild (o_id); o_td_item.appendChild (o_item); o_td_subitem.appendChild (o_subitem); o_td_opm.appendChild (label_opm); o_td_opm.appendChild (o_opm); o_td_button.appendChild (o_button); o_tr.appendChild (o_td_id); o_tr.appendChild (o_td_item); o_tr.appendChild (o_td_subitem); o_tr.appendChild (o_td_opm); o_</x-turndown>
-
I found and adapted an HTML script as shown below. It fits my needs perfectly. However, I don't know how to store the field-values of repeated lines in a javascript array that subsequently passes its contents on to a PHP-array that enables me to store the date in a MYSQL-database. I tried to fix something myself in de 3rd codeblock of de AddRow()function. A second problem is: when de line is repeated I need to reset de field values to default. Does anybody have the knowledge that I so obviously do not have? ====================================================================== function AddRow () { var o_id = document.getElementById ("id").cloneNode(true); var label_id = document.getElementById ("label_id").cloneNode(true); var o_item = document.getElementById ("item").cloneNode(true); var o_subitem = document.getElementById ("subitem").cloneNode(true); var label_opm = document.getElementById ("label_opm").cloneNode(true); var o_opm = document.getElementById ('opm').cloneNode(true); // reset field opm document.getElementById("opm").innerHTML=""; o_id.name='id[]'; o_item.name = 'item[]'; o_subitem.name = 'subitem[]'; o_opm.name = 'opm[]'; var o_button = document.createElement ("input"); o_button.type = "button"; o_button.value = "Remove"; o_button.onclick = RemoveRow; var o_td_id = document.createElement ("td"); var o_td_item = document.createElement ("td"); var o_td_subitem = document.createElement ("td"); var o_td_opm = document.createElement ("td"); var o_td_button = document.createElement ("td"); var o_tr = document.createElement ("tr"); var o_body = document.getElementById ("dynamic_table_body"); o_td_id.appendChild (label_id); o_td_id.appendChild (o_id); o_td_item.appendChild (o_item); o_td_subitem.appendChild (o_subitem); o_td_opm.appendChild (label_opm); o_td_opm.appendChild (o_opm); o_td_button.appendChild (o_button); o_tr.appendChild (o_td_id); o_tr.appendChild (o_td_item); o_tr.appendChild (o_td_subitem); o_tr.appendChild (o_td_opm); o_</x-turndown>
I'd love to help, but I'm really not clear as to what you're asking here. Can you explain further? Also, just a tip, put any code you must share inside of these tags:
<pre></pre>
Do so by clicking the 'code' button above the message box. It makes your code a lot easier to read.