Friday, 29 April 2016

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

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...