I am working with Servlet and JSP. I have a JSP form in which I have a drop down list with `id's` associated with it, as of now I have three options in the drop down list.
HTML CODE--
<form id='form' method='post' action='/test/'>
<select id="type" name="typeOne">
<optgroup id="first" name="First" label="FirstDiv">
<option value="value1" id="001">valuee1 count</option>
<option value="value2" id="002">value2</option>
<option value="value3" id="003">value3
</option>
</optgroup>
</select>
</form>
Now I need to disable few of the options in my above drop down list using jquery. Below is my jquery in which I am disabling the `option` with the list of `id's` that I get from my servlet.
`Store` is the value that I am passing from my servlet and is a `List`-
JQuery code--
<script>
$(document).ready(function () {
$(function () {
alert(<%=request.getAttribute("store") %>);
$(<%=request.getAttribute("store") %>).prop("disabled", true);
});
});
</script>
In 'Alert' I am getting the value as null
Below is my servlet from which I am passing a list which will have all my id's which I want to disable in my drop down list.
Servlet code--
List<String> storeTest = new ArrayList<String>();
storeTest.add("001");
storeTest.add("002");
req.setAttribute("store",StringUtils.join(mapForId(storeTest).toArray(),","));
this.getServletContext().getRequestDispatcher( "/myPage.jsp" ).forward( req, response );
Problem Statement:-
Now my question is - In my JSP page the options in the drop down, it does not get disabled after its been passed. Can anyone please correct me what am I doing wrong.