Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-23-2012, 10:32 PM   PM User | #1
naveendk.55
New Coder

 
Join Date: Aug 2011
Posts: 88
Thanks: 5
Thanked 0 Times in 0 Posts
naveendk.55 is an unknown quantity at this point
Question Show Manager list based on Department.

I am trying to show list of Managers based on Department selected from a dropdown. I have written the below code. But Department list is duplicated many time(as many as number of managers for that department) and not showing the values in textarea based on department selected. Help plz.

Code:
<script>

  function setText(element){
  var arr_main=document.getElementById("txtHidStr").value.split("#");
  for(var i=0;i<arr_main.length;i++)
  {
       arr_val=arr_main[i].split("@");
       if(arr_val[0]==element.value)
       {
          document.getElementById("jDesc").innerHTML=arr_val[1];
          break;
       }
  }
  }

  </script>

below is JSP CODE.

<select  name="jTitle" id="jTitle"  onchange="setText(this)">
<%
String str=""; 
Statement stt = conn.createStatement();
ResultSet rstt = stt.executeQuery("SELECT DEPT_NAME, LM_NAME  FROM   UAP_DEPARTMENT inner join UAP_LINE_MANAGER_DETAILS on DEPT_DEPARTMENT_ID=LM_DEPARTMENT_ID");
while (rstt.next()) { 
str+=rstt.getString(1)+"@"+rstt.getString(2)+"#"; 
%>
<option value="<%=rstt.getString("DEPT_NAME")%>"><%=rstt.getString("DEPT_NAME")%>
</option>
<%
 }
stt.close();
rstt.close();
%>
</select>

<input type="hidden" name="txtHidStr" id="txtHidStr" value="<%=str %>" /> 

<textarea  rows="5" cols="15" name="jDesc" id="jDesc" ></textarea>
naveendk.55 is offline   Reply With Quote
Reply

Bookmarks

Tags
java, jsp, sql

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:27 AM.


Advertisement
Log in to turn off these ads.