I am trying to read a field in a table that is of integer type. And it's also a primary key and auto-increment.
The returned value is put in a label (already tried to put in an input text too).
To read the target table and put the result in the label, I use a JQuery statement. The event is clicked on
<input type='file':
Click code is
jQuery("#idFilFoto").click(function (){
var nSigla=jQuery("#idLblSigla").text();
var tabela = "TabPessoas";
var clausulaWhere = " TabPessoasSigla = '"+nSigla+"'";
var jqxhr = $.post("genericaPegaID.php",{tabela:tabela,clausulaWhere:clausulaWhere}, function(resultado) {
jQuery("#idLblID").text(resultado);
});//fim do post
});//fim do click
This works fine.
No label
<label id="idLblID"
the value is set correctly. An integer without spaces before or after appears.
Now, I want this value inside that label to use it in another table.
This table is populated by the click event of a button.
jQuery("#idBtnSalvar").click(function (){
var tabela="TabFotos";
var campos="TabFotosCaminhoArquivo,TabFotosFKPessoas";
var matricula = jQuery("#idLblID").text();
var foto = jQuery("#idFilFoto").val();
var posicao = foto.indexOf("fakepath");
foto = foto.substr(posicao+9);
var valores="'"+foto+"',"+matricula;
alert (tabela+" : "+campos+" : "+valores);
/*
var jqxhr = $.post("genericaInserir.php",{tabela:tabela,campos:campos,valores:valores}, function(resultado) {
alert("success "+resultado);
});//fim do post
*/
});//fim do botao salvar
The commented block above is because the 'values' field forces an error in the Insert Into statement that I have in the GenericInserir.php page. It says that the value of the 'enrollment' field is non-numeric.
Actually, if you inspect what was going to the 'post' (see the alert before the commented block) appears, for example, like this:
'photo.png', [] [] 6.
Please interpret the two brackets as two closed symbols, like two rectangles.
It should be just the figure 6, in this case.
I tried
var matricula = parseInt(jQuery("#idLblID").text(),10);
but the result is NaN no alert.