Hello I’m trying to create text boxes dynamically using for loop and want to implement calendar in all of them. my code is as follows:
for (var j = 1; j <= 5; j++) {
my_proj.innerHTML = my_proj.innerHTML +'<input type="text" name="txtStartDate" id="txtStartDate"+j runat="server" BackColor="#D6E4ED" BorderStyle="Inset" Width="10px" ></input>'
+'<a href="javascript:;" onclick="window.open(\'PopUp.aspx?textbox=txtStartDate+j\',\'cal\',\'width=250,height=225,left=270,top=180\')">'
}
As I need to have separate id for all the text boxes I tried to concat the variable j with it. But its not working and giving the error as 'Unknown identifier "startDate"+j"'.
Please suggest something to solve this. Any other idea to work this out will also do. BTW I’m trying to implement it inside an .aspx page.
Thanks in advance.
Can anyone give me any other example to implement the same???? please.
You have to close the string before appending the variable to the string, so that it is recognized as a variable, and not just the letter ‘j’.
So . . .
. . . won’t work; you need to do this:
Your code should look like this: