Get the value of an Input Text according to ID

0

I'm trying to get the value of a Text input according to your ID.

in php I'm printing that way, I'm making a query. And according to the results. I'm printing with the Foreach. the amount of inputText passing them the ID.

<?php

	foreach($resultado as $row){
  	$IDcali=$row['IDcali'];
?>

 <input type="text" id="<?php echo$IDcali;?>"  min="0" max="10" name="<?php echo$IDcali;?>" class="form-control" "></th>
														      <th>
<button type="button" class="btn btn-pink" onclick="RegistroCali(<?php echo$IDcali;?>)>Guardar</button>

<?php
}
?>

<script>

function RegistroCali(IDcali){

var calificacion=document.getElementById(IDcali).value;

alert(calificacion);
alert(IDcali);

}
</script>

I'm trying to send the IDcali to the JS function. to be able to recover its value that has been introduced in the input text. but he does not recognize me. I do not know what I'm doing wrong. since if I show in the alert. it prints the value that is receiving but if I show the qualification. it says indefinitely.

    
asked by Carlos Ortiz 04.11.2017 в 18:49
source

1 answer

-1

just add the following in the cycle:

var text = $('#<?php echo $IDcali; ?>').val();

I do not know if you work with onload, onclick, keyup, etc ...

$(document).ready(function(){
    $("#<?php echo $IDcali; ?>").keyUp(function(){
            var text = $('#<?php echo $IDcali; ?>').val();
    }); 
});
  

You may have some syntax error.

    
answered by 04.11.2017 в 19:48