i using hidden's input
<input type='hidden' name='bahan' id='bahan' />
then, i want pass a value from js. i have a function called resultBtn() i get the value from it, example string var x='12,124';
i want take the value from other input
<?php $i=0; foreach ($bahanx as $pin2){
echo "<div class='input-group' style='width:175%'><label class='input-group-addon' style='width:100px'><input type='checkbox' name='bahan' aria-label='Checkbox for following text input' value='".$pin2->id_barang."' oninput='changeText(this,".$i.");' > ". $pin2->nama_barang ."</label><input type='text' class='form-control' aria-label='Text input with checkbox' name='banyak_bahan' value='0' disabled/></div><br/>";
$i++; } ?>
at resultBtn() i make a formula from bahanx then the result is x variable.
this is my js
document.getElementsByName('bahan').value=x;
document.getElementsByName('bahan')[0].value=x;