i have to add some text input dynamically on my page as following:
$table=""; $n=0;
$arrayform=array();
foreach($rslt as $rows){
$table=$table."
<div class='img-rounded row' style='margin-bottom:2%' >
<div class='col-lg-1'></div>
<div class='col-lg-4'>
<input id='cap-".$n."' type='text' class='form-control' value='".$rows['caption']."'>
</div>
<div class='col-lg-1' id='rightarrow'>
<img id='img-".$n."' src='img/right-arrow.png' width='45' height='30' alt=''/>
</div>
<div class='col-lg-4'>
<input id='val-".$n."' type='text' class='form-control' value='".$rows['value']."'>
</div>
<div class='col-lg-1'>
<input type='button' id='btn-".$n."' onClick='removeval(\"".$rows['caption']."\",\"".$rows['value']."\",\"".$_GET['id']."\",\"".$rows['id']."\")' class='btn btn-danger' value='Remove Column'>
</div>
</div>
<div id='divrslt-".$n."' class='row text-success' style='margin-left:10%; margin-bottom:2%'>
</div>
";
the id of form element's determine by $n variable and other strings.
i wrote following code to construct parameter list of input text values for send to a javascript function.
$arrayform[$rows['caption']]="cap-".$n.".value,val-".$n.".value, "; $n++;
}
And with following code i use the array that constructed in prior line as parameter to updatechartval() javascript function.
$table=$table."
<div class='row' style='margin-left:4%'>
<button type='button' class='btn btn-success' onClick='updatechartval(".implode(" ",$arrayform)."\"".$_GET['id']."\")' value='update'>
Update
</button>
</div>
";
And then i echo that:
echo $table;
the rendered button code is:
<button type="button" class="btn btn-success" onclick="updatechartval(cap-0.value,val-0.value, cap-1.value,val-1.value, cap-2.value,val-2.value, cap-3.value,val-3.value, "126")" value="update">
Update
but when i run the code, the id of element's was sent instead value of the text input's. how can i solve this? thanks...