I have something like this
<td class="standaard_klein" align="right">
<div class="timereg<?php echo $TEL;?>" id="timereg<?php echo $TEL;?>">
<i contenteditable><?php print(number_format($line2['WERKUREN'], 2, ',','')); ?>
</i>
</div>
</td>
<input type="hidden" name="hist_id" id="hist_id<?php echo $TEL;?>" value="<?php echo $line['ID'];?>">
<input type="hidden" name="counter" id="counter" value="<?php echo $TEL;?>">
and this JS function
<script type="text/javascript" language="javascript">
var counter = document.getElementById('counter').value;
$('#timereg'+counter).keypress(function(event){
if(event.keyCode == 13){
var x = document.getElementById('timereg'+counter).textContent;
var y = document.getElementById('hist_id'+counter).value;
$('#timereg'+counter).load('change_timereg.php?newtime=' + x + '&user=<?php echo $_SESSION['loginid'];?>&hist_id='+ y);
}
});
</script>
but it get only first "counter" element. How can I modify function to get specific "counter"? $TEL is counter value that I want to get. (usually it's $i but here $TEL were used).
$TEL
, and all the HTML in your first snippet part of a loop? if so, you have duplicate ID's, which is a no-no – Elias Van Ootegem 37 mins agoid
should be unique in a document, so don't useid
for thecounter
instead use a class – Arun P Johny 36 mins ago