1

I'm trying to narrow down why I'm unable to Print or even set my selected value to a string from the dropdown menu I've wrapped my JSP code around.

I'm able to display the dynamic filelist into the dropdown options successfully, however I'm unable to figure out how I can set the selected value in order to pass this down to another dynamic JSP lists based on the file selection. I found a few suggestions on this topic which I've tried out below, however I'm curious if there's more to this being this dropdown list is generated dynamically?

For now I'm just testing out the println to verify whether the "environment" string is being set properly after the selection has been made.

<select id="Environment" name="Environment_drop" onchange="document.productForm.submit();">
<%
String path = FilePath + "\\config"; // Directory path here 
                    String f;
                    File folder = new File(path);
                    File[] listOfFiles = folder.listFiles();

                    for (int i = 0; i < listOfFiles.length; i++) {
                        if (listOfFiles[i].isFile()) {
                            f = listOfFiles[i].getName();
                            out.println("<option value=" + f + ">" + f + "</option><BR>");
                        }
                    }                   
%>
</select>
<span></span>
</section>
<%
        String[] environment = request.getParameterValues("Environment");
        out.println(environment);
%>
        <script>
        document.getElementById("Environment_drop").value = '<% out.print(environment); %>';
        </script>
Curtis
  • 657
  • 1
  • 7
  • 15

0 Answers0