Passing values from a dynamicaly created form to new page
Posted: Wed Jun 03, 2009 2:07 pm
First I have to say I am terrible at PHP, like i get it, but i just can't do it (if that makes any sense). I am not a natural programmer, client side i'm good, server side
. Anyways, here is my issue.
I have a page that will dynamically create a form. The purpose of this form is to create a mysql table using the values of the form. That I am more that confident I can do, the problem I am having is trying to figure out how to pass those values to another PHP page.
Here is the code of the page
How would i get it to pass the values of this dynamic form to another PHP page?
THanks for your help
I have a page that will dynamically create a form. The purpose of this form is to create a mysql table using the values of the form. That I am more that confident I can do, the problem I am having is trying to figure out how to pass those values to another PHP page.
Here is the code of the page
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Form Generator</title><script src="ajax.js" type="text/javascript"></script><link rel = "stylesheet" type = "text/css" href = "tsehkay.css" /><script language="javascript" type="text/javascript">function validate() { alert('function called'); }//Add more fields dynamically.function addField(field,fname,limit) { if(!document.getElementById) return; //Prevent older browsers from getting any further. var field_area = document.getElementById(field); var field_name = document.getElementById(fname).value; var all_inputs = field_area.getElementsByTagName("input"); //Get all the input fields in the given area. //Find the count of the last element of the list. It will be in the format '<field><number>'. If the // field given in the argument is 'friend_' the last id will be 'friend_4'. if (all_inputs.length > 0) { // something has been entered var last_item = all_inputs.length - 1; var last = all_inputs[last_item].id; var count = Number(last.split("_")[1]) + 1; } else { // nothing has been entered yet count = 0; } //If the maximum number of elements have been reached, exit the function. // If the given limit is lower than 0, infinite number of fields can be created. //W3C Dom method. var remove_entry = "<a style='cursor:pointer;' onclick='this.parentNode.parentNode.removeChild(this.parentNode);'>Remove Field</a> "; //var ne = document.createElement("span");// ne.innerHTML=remove_entry; var li = document.createElement("li"); li.innerHTML = remove_entry + " FIELD" + (count+ 1) + ": "; var input = document.createElement("input"); input.id = "field_"+ count; // alert (input.id); input.name = "field_"+ count; input.type = "text"; //Type of field - can be any valid input type like text,file,checkbox etc. input.value = field_name; li.appendChild(input); //li.appendChild(ne); field_area.appendChild(li); } </script> </head> <body> <div id="content2"> <h1>Form Generator</h1> <strong>NOTE</strong>: This system is currently under development, and there may be changes. <form name="frm" method="POST"><H3>ADD NEW FIELD:</h3><br />Field Name: <input type="text" name="field_name" id="field_name" maxlength="50" /><br />Data Type: <select name="data_type" id="data_type"><option>Text</option><option>Numeric</option></select><br /> <input type="button" value="Add Field" onclick="addField('new_fields','field_name', 'field_type');" /> </form> <hr /><H3>FIELDS ADDED:</H3> <form action="table.php" method="POST" name="form_gen"><strong>Table Name: </strong><input type="text" name="new_table" id="new_table" /><br /><ol id="new_fields"> </ol><input type="hidden" name="create_form" id="create_form" value="Y" /><input type="submit" name="form_gen" value="Finished" /></form> </div> </div></body> </html>THanks for your help