Can some one tell me how can I achieve this javascriptVariable=AspVariable concatenated with javascript incrementing variable;
ie I want to change the left hand side of the equation dynamically,here is how I tried to do it and FAILED:
for(j=1;someCondition;j++)
{
eval("job"+j).Sdate=parseInt('<%= djobSdate[%>'+j+'<%=] %>');
}
the right hand side works fine but the left hand side of the equation gives problem
To get the result of server side function djobSdate() by passing javascript variable j, you will need to use AJAX.
This is because the variable j has its value calculated client side.
Look into using ASP.NET Web Services with jQuery AJAX
You may find this article useful:
http://encosia.com/using-jquery-to-consume-aspnet-json-web-services/
Then your code would change to something like:
for(j=1;someCondition;j++)
{
$.ajax({
type: "POST",
url: "myWebService.asmx/GetdjobSdate",
data: '{j: "' + j + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
eval("job"+j).Sdate=parseInt(data);
}
});
}
And your web service would look something like:
[System.Web.Script.Services.ScriptService]
public class myWebService : System.Web.Services.WebService
{
[WebMethod]
public string GetdjobSdate(j)
{
return djobSdate(j);
}
}