I have developed a nice piece of JavaScript that creates new form elements:
Code: Select all
function addT(){
var root = document.getElementById('container');
var clone = root.getElementsByTagName('div')[0].cloneNode(true);
var txt=clone.getElementsByTagName('input');
txt[0].value='URL';txt[1].value='label';
var but=document.createElement('input');
but.setAttribute('type','button');
but.setAttribute('value','Trash');
but.onclick=function(){remT(this.parentNode)}
clone.insertBefore(but,txt[1].nextSibling)
root.appendChild(clone)
renameID()
}
function remT(p){
p.parentNode.removeChild(p);
renameID();
}
function renameID(){
var divs=document.getElementById('container').getElementsByTagName('div');
for(var i=0;i<divs.length;i++){
divs[i].getElementsByTagName('input')[0].name='link'+(i+1);
divs[i].getElementsByTagName('input')[1].name='label'+(i+1);
}
}How do I handle the posted data? I've used the generic form handling script from the PHP manual to perform a var_dump() on all of the submitted information, and it's all there...
I can't figure out how to pair up the resultant $_POST data correctly (link1 with URL1, link2 with URL2 etcetera) and then: 1> echo them out; 2> Pass their value to a hidden field and; 3> Place the values into the database for output later (after form submission). An example of the code running in it's present state can be seen here: http://www.sageinteractive.co.uk/cms/in ... ation2.php
This is for a navigation builder where the user can add links to a "toolbar", and I need to be able to show a preview of the end result using the data submitted from the previous page. It is the most complex part of an app that I am developing currently, and I really need some help to sort out the code that 1> Provides the preview and; 2> Inserts the information into the database in such away that it can be easily accessed and manipulated in the final output.
Thanks in advance