...

View Full Version : getting data from dynamic fields



ag1060
09-14-2011, 11:58 PM
Hello,

I have a problem regarding getting values from dynamic textfields/checkboxes.

Firstly,

I have this JavaScipt which creates dynamic txtbxs/checkbx like this when they click "Add Stage" / "Remove Stage" buttons: http://oi51.tinypic.com/33mwua8.jpg





<script type="text/javascript">
var currentTxtBx = 0;
function addTxtBx(){


if (currentTxtBx >= 15) {
alert("You've reached the maximum number of stages.");
}else{

var txtBxHolder = document.getElementById('txtBoxHolder');

var newTxtBx = document.createElement('input');

var newTxtBx1 = document.createElement('input');





newTxtBx.type = 'text';
newTxtBx.name = "stage";
newTxtBx.value = 'stage'+(currentTxtBx+1);

newTxtBx1.type = 'checkbox';



currentTxtBx++;

var allTxtBxs = document.getElementById('txtBoxHolder').getElementsByTagName('input');



txtBxHolder.appendChild(newTxtBx);
txtBxHolder.appendChild(newTxtBx1);


}
}

function removeTxtBx(){
var allTxtBxs = document.getElementById('txtBoxHolder').getElementsByTagName('input');
var allTxtBxs1 = document.getElementById('txtBoxHolder').getElementsByTagName('input');


if (allTxtBxs.length == 0){
alert('There are no stages to remove.');
} else {
document.getElementById('txtBoxHolder').removeChild(allTxtBxs[allTxtBxs.length-1]);
document.getElementById('txtBoxHolder').removeChild(allTxtBxs1[allTxtBxs1.length-1]);
currentTxtBx = allTxtBxs.length;
}
}
</script>

....

<input type="button" value="Add stage" onclick="addTxtBx()">
<input type="button" value="Remove stage" onclick="removeTxtBx()">



Now the problem is getting PHP to get those dynamic values. I tried the formal $_POST['stage'] and of course didn't go through.


any suggestion?


Thanks in advance

-aaron

>ssp-cdr<
09-15-2011, 12:27 AM
You can use echo var_dump($_POST); to see what parameters are being sent through to PHP.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum