mercredi 25 mars 2015

Printing PHP string using JQuery

I got a script which uses an array that was created in PHP and was encoded to JSON. It then take the string and use it to set a value for an element I created:



var val ="";
if(arr != null)
{
if((arr[i] != undefined) && (arr[i]["value"] != undefined))
{
var val = JSON.stringify(arr[i]["value"]);
val.replace(/"/g , "");
}
}
cell.innerHTML = "<input type='text' value='"+val+"' style='padding-right: 0px;'/>";


The problem is that every string on the screen appears with the "" around the string itself. for example "5". I want it to be just 5 and not "5". I thought the replace I did to the val was supposed to do it but it didn't work. why is that?


Aucun commentaire:

Enregistrer un commentaire