Question

I am using on my web page input array:

<input id='idInput[1]' />

And with some JavaScript function I am able to set the value of this input:

$('#idInput\[1\]').val(5);

Problem is that the ID of input which I want to set I have to send back to server (using AJAX) and after it send back the response, but because of backslash I need to add so many backslash because of AJAX processing, PHP processing and the end jQuery processing. So at the end it looks like:

ajaxSetIdWithResult("idInput\\\\\\\\[1\\\\\\\\]");

With this solution it is working well but I feel that is horrible. So can do it better?

Was it helpful?

Solution

Try this:

instead #idInput[1] change id like below


<input id='idInput_1' />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top