Just replace it with
var tempEnd='A';
tempEnd = String.fromCharCode(tempend.charCodeAt(0) + 1);
Domanda
I'm trying to increment a letter used in a recurring function, This function is called every time a user selects another possible end point. However it keeps using the name B, is there a way to increment it each time?
var tempEnd = String.fromCharCode('A'.charCodeAt(0) + 1);
/* create end point */
function end_point(t) {
calculate_start = false;
name = tempEnd;
marker = new nokia.maps.map.StandardMarker(coordinate, {
text: name,
draggable: true,
e_num: end_ar.length
});
marker.addListener("drag", dragAndDrop, true);
marker.addListener("dragend", dragAndDrop, false);
document.getElementById("points").style.display = 'none';
map.objects.add(marker);
if (t == true) {
map.zoomTo(map.getBoundingBox());
}
end_ar.push(coordinate);
createTable();
};
Thanks
Soluzione
Just replace it with
var tempEnd='A';
tempEnd = String.fromCharCode(tempend.charCodeAt(0) + 1);
Altri suggerimenti
Seems like you want to use tempEnd to increment, in which case you could store name externally and then call it each time you want to increment:
//store name
var name = "A"
//create tempEnd incrementation
function tempEnd(str){
var number = 1;
letter = String.fromCharCode(str.charCodeAt(0) + number);
number++;
return letter;
}
//call name on tempEnd
name=tempEnd(name);
name=tempEnd(name);
//name is now "C"