• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I change the content of the combo box based selction on other combo box.

 
sarasah guna
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have huge problem , please help me soon .The promblem is that I have 2 combo box know as rea_cde combo box and tran_typ combo box .I want the content of the rea_cde combo box change based on the selection made in tran_typ combo box .But currently I the value is not checked .
the combo box display the value. Not based on the criteria. Below is my coding
function setReasonCode(obj){
<%String sql_query3 = "SELECT DISTINCT (ir_tran_typ) "+
" FROM intrcd ";
System.out.println("trans type"+sql_query3 );
try{
rset = db.execSQL(sql_query3);
}
catch(SQLException e) {
System.err.println("Error in query - intrcd - transaction_main.jsp " +e +" sql " +sql_query3);
}
while(rset.next()){
tran_cde = rset.getString("ir_tran_typ");

tran_typ.addElement(rset.getString("ir_tran_typ"));
System.out.println("trans type 34 "+tran_typ );%>
<% }%>
alert(obj.value);
<%for(int i=0 ;i<tran_typ.size();i++){
System.out.println("trans type 222 "+ tran_typ.size());
tran_cde =tran_typ.elementAt(index).toString();%>
<%System.out.println("trans type before "+ tran_cde);%>

if(D == <%=tran_cde%> ){
<%System.out.println("trans type D"+ tran_cde);%>
<%String sql_query2 = "SELECT ir_rea_cde,ir_rea_desc"+
" FROM intrcd"+
" WHERE ir_tran_typ = 'D' " +
" ORDER BY ir_rea_cde ";
System.out.println("query"+ sql_query2);
try{
rset = db.execSQL(sql_query2);
}
catch(SQLException e) {
System.err.println("Error in query - emmast2 - transaction_main.jsp " +e +" sql " +sql_query2);
}
index = 1;
while(rset.next()){
rea_cde = rset.getString("ir_rea_cde");
rea_desc = rset.getString("ir_rea_desc");
tran_typ.removeAllElements();
}%>
}
if( R == obj.value){
alert(R)
if(R== <%=tran_cde%> ){
<%System.out.println("trans type R"+ tran_cde);%>
<% sql_query2 = "SELECT ir_rea_cde,ir_rea_desc"+
" FROM intrcd"+
" WHERE ir_tran_typ = 'R' " +
" ORDER BY ir_rea_cde ";
System.out.println("query 2"+ sql_query2 );
try{
rset = db.execSQL(sql_query2);
}
catch(SQLException e) {
System.err.println("Error in query - intrcd - transaction_main.jsp " +e +" sql " +sql_query2);
}
index = 1;
while(rset.next()){
rea_cde = rset.getString("ir_rea_cde");
rea_desc = rset.getString("ir_rea_desc");
}%>
}}
<%}%>

}
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sarasah,

Javaranch tip:

If you are going to post more than a line or two of your code, wrap that
code in a set of UBB Code tags.
Doing so will help to preserve your code's indenting, making it easier to read.
If it is easier to read, more people will actaully read it and you will
stand a better chance of getting help with your question.




[Klunk!]
[ December 23, 2005: Message edited by: Ben Souther ]
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way you posted the code makes code more messy then it would be when indented. Please use UBB code tag while posting code.

Well, if you want to do this on client-side then you had better post it in HTML forum. Otherwise, you can take the selected value of the first combo and get the values of second combo, based on selected value, from DB or whatever. After that fill the combo with appropriate values. Where is the problem?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!