Rel82me
01-11-2014, 08:44 PM
For anyone who can provide some assistance I would appreciate it.
Have a portion of a registration system that asks the end user for a URL, then allows the user to add additional URLS's by clicking the "Add Additional URL" button & function. Here's the Form portion:
------------
<td>
<div id="dynamicInput">Uniform Resource Locator 1:<br><input type="text" name="myInputs[]" placeholder="http://www.mydomainname.com">
</div><br/>
<input type="button" value="Add Additional URL's / Domains" onClick="addInput('dynamicInput');">
</td>
-------------
Here's the function portion:
-------------
var counter = 1;
var limit = 3;
function addInput(divName){
if (counter == limit) {
alert("You have reached the limit of adding " + counter + " inputs");
}
else {
var newdiv = document.createElement('div');
newdiv.innerHTML = "Uniform Resource Locator: " + (counter + 1) + " <br><input type='text' name='myInputs[]' placeholder='http://www.mydomainname.com'>";
document.getElementById(divName).appendChild(newdiv);
counter++;
}
}</script>
---------------
How do I get this array into my database table? The database portion works, no problem as all the other user info get's inserted and of course, I already have fields for the 3 additional URL's.
I'm assuming else statement is generating the following variables, dynamically: myInputs[0], myInputs[1], myInputs[2] or ..1..2..3. So not to sure if I should be using:
$myInputs1 = $_POST['table field name'];
$myInputs2 = $_POST['table field name''];
then a sql insert statement, or what??
maybe foreach($_POST as ........)
???
Have a portion of a registration system that asks the end user for a URL, then allows the user to add additional URLS's by clicking the "Add Additional URL" button & function. Here's the Form portion:
------------
<td>
<div id="dynamicInput">Uniform Resource Locator 1:<br><input type="text" name="myInputs[]" placeholder="http://www.mydomainname.com">
</div><br/>
<input type="button" value="Add Additional URL's / Domains" onClick="addInput('dynamicInput');">
</td>
-------------
Here's the function portion:
-------------
var counter = 1;
var limit = 3;
function addInput(divName){
if (counter == limit) {
alert("You have reached the limit of adding " + counter + " inputs");
}
else {
var newdiv = document.createElement('div');
newdiv.innerHTML = "Uniform Resource Locator: " + (counter + 1) + " <br><input type='text' name='myInputs[]' placeholder='http://www.mydomainname.com'>";
document.getElementById(divName).appendChild(newdiv);
counter++;
}
}</script>
---------------
How do I get this array into my database table? The database portion works, no problem as all the other user info get's inserted and of course, I already have fields for the 3 additional URL's.
I'm assuming else statement is generating the following variables, dynamically: myInputs[0], myInputs[1], myInputs[2] or ..1..2..3. So not to sure if I should be using:
$myInputs1 = $_POST['table field name'];
$myInputs2 = $_POST['table field name''];
then a sql insert statement, or what??
maybe foreach($_POST as ........)
???