• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

need help dependent dropdown list

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
each value has 2 words separate by space for example full name "Vijay deshanur" while I get it using getParameter it is showing only the first word i.e "vijay".

ArrayList Applist=new ArrayList();
String query="select PHASE3SERVICENAME FROM itdtim3.APPLIST";
rs=stmt.executeQuery(query);

while(rs.next())
{
Applist.add(rs.getString(1));
}

log(" value "+Applist); // Displaying correctly
request.getSession().setAttribute("Applist",Applist);


String app = (String)request.getParameter("Applist");
log("value "+app); //Displaying wrong.

kindly help



 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Most likely your HTML is malformed. This sort of thing happens most often when the HTML is sloppy and doesn't use quotes to contain the attribute values.
 
vijay deshanur
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<!--
/********************************************************************
* Licensed Materials - Property of IBM
*
* (c) Copyright IBM Corp. 2007 All Rights Reserved
*
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with
* IBM Corp.
********************************************************************/
-->
<%@ page import="java.util.*,java.sql.*,java.text.SimpleDateFormat" %>
<%@ page language="java" %>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="com.ibm.itim.common.AttributeValue"%>
<%@ include file="sample_utils.jspf" %>

<%
String SIAappList="appselected";
String SIAITDlist="userselected";
String DEST_ATTR="attachment";
%>


<html>
<head>
<%=printStatusInfo(request)%>

<title>Application / ITD User List</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<link rel="stylesheet" href="images/style.css"
type="text/css">
</head>

<SCRIPT LANGUAGE="JavaScript">

function setIndex(){

if('<%=request.getParameter("selectedapplistindex")%>'!="null" || '<%=request.getParameter("selectedapplistindex")%>'!="")
{
var index='<%=request.getParameter("selectedapplistindex")%>';
document.forms[0].Applist.selectedIndex=index;
document.forms[0].selectedapplistindex.value=index;
}

if('<%=request.getParameter("selecteditdlistindex")%>'!=null || '<%=request.getParameter("selecteditdlistindex")%>'!="")
{
index='<%=request.getParameter("selecteditdlistindex")%>';
document.forms[0].itdUserList.selectedIndex=index;
document.forms[0].selecteditdlistindex.value=index;
}
}
function cancel()
{
window.self.close();
}
</script>

<b>Service Selected <%=getServiceName(request)%></b>
<%
String close=(String)request.getParameter("submitted");

if(close != null && close.equalsIgnoreCase("true"))
{

try
{

ArrayList list= new ArrayList();
list.add(0,request.getParameter(SIAappList));
list.add(1,request.getParameter(SIAITDlist));
AttributeValue av= new AttributeValue(DEST_ATTR,list);
log("destination attribute value:"+request.getParameter(SIAappList));
request.getSession(false).setAttribute("subFormAttrValue",av);
}
catch(Exception e)
{
log("Error Message from the log :"+e.getMessage());
}

}


%>
<%
close=(String)request.getParameter("submitted");
if(close != null && close.equalsIgnoreCase("true"))
{
%>
<body onLoad="cancel()">
<%
}
else
{%>
<body>
<%}
%>





<form method="POST" >
<body bgcolor="#666666" onload="setIndex()">
<input name = "selectapplist" type = "hidden" value = "false"/>
<input name = "selectitdlist" type = "hidden" value = "false"/>
<input type="hidden" name="selectedapplistindex" value=null>
<input type="hidden" name="selecteditdlistindex" value=null>
<table width="800" height="425" align="center"
border="1" bgcolor="#FFFFFF" cellpadding="0"
cellspacing="0" class="text"

bordercolor="#CCCCaa">
<tr>
<td width="800" height=175 align=center valign=middle>
<table border=1 width=300
bordercolor="#CCCCaa">
<tr bgcolor="CCCa030">
<td colspan="2" align="center"><b
class="content4">SELECT APPLICATION & ITD USER</b></td>
</tr>


<%
String driverName = "com.ibm.db2.jcc.DB2Driver";
java.sql.Statement stmt=null;
ResultSet rs=null;
Class.forName(driverName);

// Create a connection to the database
String serverName = "ipaddress";
String portNumber = "50000";
String url = "jdbc:db2://" + serverName + ":" + portNumber + "/TIM3U01";
//jdbc:db2://ipaddress:50000/TIM3U01
String username = "itimuser";
String password = "password";
ArrayList Applist=new ArrayList();
ArrayList itdUserList=new ArrayList();
Connection connection=null;

%>

<%
try{

connection = DriverManager.getConnection(url, username, password);
stmt=connection.createStatement();
String servicename = getServiceName(request);
String query="select PHASE3SERVICENAME FROM itdtim3.APPLIST";// WHERE PHASE2SERVICENAME LIKE '" + servicename + "'";
rs=stmt.executeQuery(query);

while(rs.next())
{
Applist.add(rs.getString(1));
}

log(" value "+Applist);
request.getSession().setAttribute("Applist",Applist);


rs.close();
stmt.close();
connection.close();
connection=null;
}
catch(Exception e)
{
e.printStackTrace();
}

%>


<tr bgcolor="CCCCCC">
<td class="content1">*Application List</td>
<td class="text">

<select name="Applist" onChange="getApplicationList(this.form.Applist)">
<option value=""></option>
<%
ArrayList app3list=(ArrayList)request.getSession().getAttribute("Applist");
int pcount = app3list.size();
for(int i=0; i<pcount; i++) {
String selected = "";

%><option <%=selected%> value=<%=(String)app3list.get(i) %>
><%=app3list.get(i) %></option><%}%> </select>


</td>
</tr>



<%
if(request.getParameter("selectapplist")!=null && request.getParameter("selectapplist").equals("true") )
{
try{
connection = DriverManager.getConnection(url, username, password);
stmt=connection.createStatement();
String ma = (String)request.getParameter("Applist");
log("-ma-"+ma);
String query="select ITDUSERName ,ITDEMPNUMBER FROM itdtim3.ITDLIST"; //WHERE PHASE3SERVICENAME LIKE '" + Applist1 +"'";
rs=stmt.executeQuery(query);
while(rs.next())
{
itdUserList.add(rs.getString(2));
}

request.getSession().setAttribute("itdUserList",itdUserList);
connection.close();
connection=null;
}catch(Exception e){
//log("Hello Vijay2");
e.printStackTrace();
}
}

%>

<tr bgcolor="CCCCCC">
<td class="content1">*ITDUser List </td>
<td class="text">

<select name="itdUserList" onChange="getITDUserList(this.form.itdUserList)">
<option value=""></option>
<%
if((request.getParameter("selectapplist")!=null && request.getParameter("selectapplist").equals("true"))||(request.getSession().getAttribute("itdUserList")!=null))
{
ArrayList UserList=(ArrayList)request.getSession().getAttribute("itdUserList");
int pcount2 = UserList.size();
for(int i=0; i<pcount2; i++) {
String selected = "";

%><option <%=selected%> value=<%=(String)UserList.get(i) %>
><%=UserList.get(i) %></option><%}}%> </select>

</td>
</tr>



</table>

</form>
<form method ="POST" >
<table>
<tr>
<td width="153"> </td>

<input type="button" value="Submit" name="add" onClick="add1()"> 


<input name = "appselected" type = "hidden" value = null/>
<input name = "userselected" type = "hidden" value = null/>
<input name = "submitted" type = "hidden" value = "false"/>
<input type="hidden" name="operation" value="add">

</tr>
</table>
</form>

</body>

<SCRIPT LANGUAGE="JavaScript">

function getApplicationList(dropdown){

var frmObj = document.forms[0];

var myindex = dropdown.selectedIndex;
var SelValue = dropdown.options[myindex].value;

document.forms[0].Applist.value =SelValue;
document.forms[0].selectapplist.value="true";

document.forms[0].selectedapplistindex.value = myindex;
document.forms[0].submit();

}

function getITDUserList(dropdown){

var frmObj = document.forms[0];
var sel=frmObj.Applist.options[frmObj.Applist.selectedIndex].value;
document.forms[0].Applist.value =sel;
sel=document.forms[0].itdUserList.options[document.forms[0].itdUserList.selectedIndex].value;
document.forms[0].itdUserList.value=sel;
document.forms[0].selectapplist.value="false";
document.forms[0].selectitdlist.value="true";
document.forms[0].selecteditdlistindex.value = document.forms[0].itdUserList.selectedIndex
document.forms[0].action="";
document.forms[0].submit();

}
function add1()
{

var v=document.forms[0].Applist.value;
document.forms[1].appselected.value=v;

v=document.forms[0].itdUserList.value;
document.forms[1].userselected.value=v;

document.forms[1].submitted.value="true";
document.forms[1].submit();
}
</SCRIPT>
</html>
 
Bear Bibeault
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sigh... still putting Java code into JSPs? in 2011?

In any case, yes, the HTML is malformed and sloppy. Take a look at the rendered HTML in the browser and you will see the problem with the option tags.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic