Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I would like to modify a html input array value, just append an input text field for all the array.

The array form create with php. I need the idnap field to append from another input, name and id: datum1.

$count = 0;
while($eredmeny = mssql_fetch_assoc($result))
{   
$table_results  = '<tr style="color: #000e94; font-size=12" align="center" valign="middle">';
$table_results .= '<td>';
$table_results .= "<input type='checkbox' name='form[$count][id]' id='form[$count][id]' value='{$eredmeny['ID']}'>"; 
$table_results .= '</td>';
$table_results .= '<td><input type="text" name="form[$count][idnap]" id="form[$count][idnap]" value="' . $eredmeny['ID'] .'" style="width:130px;"></td>';   
$table_results .= '<td><input type="text" name="form[$count][feladat]" id="form[$count][feladat]" value="' . $eredmeny['Feladat'] .'" style="width:130px;"></DIV></td>';
$table_results .= '<td><b><input type="text" name="form[$count][hatarnap]" id="form[$count][hatarnap]" value="' . date_format(date_create($eredmeny['Hatarido_alap']), 'd') .'" style="width:20px;">nap</b>';
$table_results .= '<input type="text" name="form[$count][hatarora]" id="form[$count][hatarora]" value="' . date_format(date_create($eredmeny['Hatarido_alap']), 'H:i:s') . '" style="width:55px;"></td>';
$table_results .= '<td>' . $eredmeny['Tipusa'] . '</td>';
$table_results .= '</tr>';
echo $table_results;
$count++;
}

My javascript it tried last, I called it with input datum1 onclick.

function datumozo () 
   {    
      var mycontrols=document.getElementById('idnap[]');
      var ertek=document.getElementById('datum1').value;

      for(var i=0;i<mycontrols.length; i++)
      {
        alert('1');
        myControls[i].value = myControls[i].value + ertek.slice(0,4);
        myControls[i].value = myControls[i].value + ertek.slice(5,7);
        myControls[i].value = myControls[i].value + ertek.slice(8,10);
      }  
    }
share|improve this question
    
My form works well, another javascript, what is check all of checkboxes also, but this append function is not. –  Woodyka Mar 3 at 11:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.