I'm a newbie so forgive me if my terminology doesn't make sense. Here goes....
If I have the following variables in JS:
var LE_TotalAnnualIncome = "50000";
var LE_TypeOfSP = "Single";
var LE_NoDependants = "1";
var LE_Customer = "3000";
How can I convert the string:
MinimumLivingExpenses(LE_TotalAnnualIncome,LE_TypeOfSP,LE_NoDependants,LE_Customer)
To:
MinimumLivingExpenses("50000","Single","1","3000")
Edited to add this: This code might explain what I'm trying to achieve:
function Calculate()
{
var elements = frm_livingexpenses.elements;
var el;
var reClass = /(^|\s)inputCalculated(\s|$)/;
// Searches for fields that need to be calculated
for (var i=0, iLen=elements.length; i<iLen; i++)
{
el = elements[i];
if (reClass.test(el.className))
{
// if contents of element are a formula, calculate result
// the element will have an '=' if it's a formula
var GetFormula = document.getElementById(elements[i].name).getAttribute('data-formula');
if (GetFormula.substring(0,1) == '=')
{
elements[i].value = eval(GetFormula.substring(1,999));
eval(elements[i].name.substring(12,999) + '="' + elements[i].value + '";');
// this is where the variables are set. eg
// var LE_TotalAnnualIncome = "50000";
// var LE_TypeOfSP = "Single";
// var LE_NoDependants = "1";
// var LE_Customer = "3000";
}
// if contents of element are a function call, send to function
// the element will have a '#' at the front if I need to call a function
if (GetFormula.substring(0,1) == '#')
{
// eg. #MinimumLivingExpenses(LE_TotalAnnualIncome,LE_TypeOfSP,LE_NoDependants,LE_Customer)
// this should be: MinimumLivingExpenses("50000","Single","1","3000")
alert('Ajax call will use this in URL='+GetFormula.substring(1,999));
}
}
}
}`