Hello guys/gals,
I am currently working on a web application for work, and was wondering if anybody could offer a quick solution.
I am using a JQuery function that allows the users to dynamically add additional forms to an HTML file.
Each dynamically added form is assigned a unique ID. such as rdBullet1, rdBullet2, rdBullet3, etc. etc.
My JQuery function can be viewed below.
What I need help with is writing a PHP script that can check to see how many of these unique forms exists, then echo the value of the form for each unique form.
Use to I had a set number of forms and I created a php script that would check if the form was empty, if not it would echo the value of the form..
ExampleCode
<?php if (!empty($_POST["rdBullet1"])) {echo "<li>" .$_POST["rdBullet1"];} ?>
Currently, I'm trying the following code, however it's not working as intended. It might be because my php variable usage.
Code
<?php
$bulletID = 1;
while (isset($_POST["rdBullet$bulletID"])) {
echo "<li>" .$_POST["rdBullet$bulletID"];
$bulletID++;}
?>
JavaScript:Code
<script type="text/javascript" charset="UTF-8">
$(document).ready(function(){
var nextBulletID = 0;
$("#rdAddBullet").click(function () {
var bulletID = ++nextBulletID;
$("#addDesc").append('<tr><td><label>Bullet ' + bulletID + '</label></td><td><input type="text" name="rdBullet' + bulletID + '" id="rdBullet' + bulletID + '"></td></tr>')
});
});
</script>
This post was edited by grievance on Sep 16 2013 11:34am