Saturday 3 August 2019

javascript convert object to string

I have some form with several values depending which is selected









Now script



$(document).ready(function() {

$("#go").click(function() {

// Obtener la referencia a las listas
var lista1 = eval(document.getElementById("tropa1"));
// Obtener el valor de la opciĆ³n seleccionada
var valort1 = eval(lista1.options[lista1.selectedIndex].value);
var cadena = String(valort1);
console.log("PHP: " + String(valort1));
if (cadena.indexOf('z') != -1) {
// value selected in options does not contain 'z'
console.log("DOES NOT CONTAIN Z");
console.log(cadena);

confront(nu1, valort1, nu2, valort2)

} else {
//// value selected in options contains 'z'
console.log("CONTAINS Z");
console.log(cadena);
}
})

});


I tried to make this, but console return : [object Object] and not show string.
even using String() function or eval() to convert object to a string

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...