I have a problem with my JavaScript code.
I want to check if a variable with dynamic name exist, but I don't know how to do it. I tried to do something, but it doesn't work
If someone could help me, I would be very grateful. Thx, Alessio
function addElement(id_sub, id_v){
var n_id_sub = document.getElementById('sub'+id_sub).value;
var name = "tot" + id_sub;
checkName(name);
var n_prod = document.getElementById('number'+id_v).value;
if(n_prod>=2){
alert(n_prod)
}else{
var inputField=document.getElementById('number'+id_v);
inputField.value=parseInt(n_prod)+1;
}
}
function checkName(n){
if(typeof window['name'] === 'undefined'){
var window['name'] = 0;
}
}
EDIT: Sorry, I didn't make myself clear, I'm currently studying to improve my English. I want to create a js file that retrieve a value from an HTML form. I need to check if there is a variable that has the retrieved value as its name.