Reputation: 1263
In my Spring MVC application, I have dynamic buttons.
<input type="button" id="button${id}" class="btn register" value="Add a Option" onclick="processId(${id})"/>
Based on another click action above number of buttons will increase. so I have buttons as button1,button2,button3,button4 etc.
Now click on each button I am calling processId(id)
function by passing the id
value.
On this processId(id)
function I am doing get call to my spring controller.
where I am passing two parameter, this id and increment of another variable.
I am struggling, for second parameter.
function processId(id) {
$.get("<%=request.getContextPath()%>/processId", { id: id,secondId:secondId,},
function(data){
$("#submitIdOptionRow"+id).before(data);
});
}
How to increase secondId
value for click event of one id
.
Suppose I click on
button2
- 1st click - parameter will be 2,0
- 2nd click - paramter will be 2, 1
- 3rd click - paramter will be 2, 2
button3 - 1st click - parameter will be 3,0 - 2nd click - paramter will be 3, 1
looks like need a double dimension array/ Map, a key-value pair.where id is the key and value is the second parameter. if id(button2) is available on map, get the value (second parameter) and increase it to one more Else id(button2) is not available.then put in the array both key and value(2,0)
This kind of logic I can handle in java using util map.But in jquery I am poor. Please help me, how to achieve this.
Upvotes: 0
Views: 139
Reputation: 1377
If map is function alone is your problem, in javacript also you have the map function. Please check this MDN Documentation.
From the browser compatability stand point, it is supported only in IE 9+
Upvotes: 0