Passing parameters in a pop window again..
hi.. here is my code.. my problem is once you click the button and it opens window with data but the error is "null".. anyone can correct my code in passing a parameter.. thanks in advance
PAGE1
<script language="JavaScript">
function NewWindow (jsppage,cmbmonth,cmbyear)
{
page = jsppage+"?cmbmonth="+cmbmonth+ "&cmbyear=" +cmbyear
document.getElementById(page).onclick = popUp;
window.open(jsppage,"","height=250,width=400,status=no,location=no,toolbar=no,directories=no,menubar=no");
}
</script>
<body>
<DIV align="center">
<P class="style11">SP 2 </P>
</DIV>
<DIV align="center">
<form name="formyear" method="post" action="SP_2.jsp">
<table cellspacing="2" cellpadding="2" border="0" width="20%">
<tr>
<td width="46%" height="26" valign="middle" class="style5"><div align="right">MONTH : </div>
<td width="54%" valign="middle"><select name="cmbmonth">
<option value="1">1</option>
<option value="1">2</option>
<option value="1">3</option>
<option value="1">4</option>
<option value="1">5</option>
<option value="1">6</option>
<option value="1">7</option>
<option value="1">8</option>
<option value="1">9</option>
<option value="1">10</option>
<option value="1">11</option>
<option value="1">12</option>
</select>
<tr>
<td valign="middle" class="style5"><div align="right">YEAR : </div></td>
<td valign="middle"><select name="cmbyear">
<option value="2005">2005</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
<option value="2011">2011</option>
<option value="2012">2012</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
<option value="2016">2016</option>
<option value="2017">2017</option>
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
</select></td>
</tr>
<tr><td height="24"></td>
<td height="24"><input name="submit" type="submit" value="Submit"/>
</table>
<P> </P>
<input type ="button" onclick="NewWindow ('SP_2.jsp', this.form.cmbmonth.value,this.form.cmbyear.value)" >
</form>
</DIV>
</body>
</b>
</html>
PAGE 2
<%@ page contentType="text/html;charset=iso-8859-1" import="java.sql.*,Connect.CRMCon"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>untitled</title>
</head>
<body>
<%
logparameters data = new logparameters();
data.cmbmonth = request.getParameter("cmbmonth");
data.cmbyear = request.getParameter("cmbyear");
%>
<b><center>WORLD OF FUN </b></center>
<center>Comparative Sales Report </center>
<table cellspacing="1" cellpadding="1" border="1" >
<tr>
<td width="7%" height="21" class="style4">
<DIV align="center" class="style5"><strong>Company Code</strong></DIV></td>
<td width="8%" height="20" class="style4">
<DIV align="center" class="style5"><strong>Branch Code</strong></DIV></td>
<td width="8%" height="20" class="style4">
<DIV align="center" class="style5"><strong>Sales Quota</strong></DIV></td>
<td width="9%" height="20" class="style4">
<DIV align="center" class="style5"><strong>Month Sales</strong></DIV> </td>
<td width="9%" height="20" class="style4">
<DIV align="center" class="style5"><strong>% Achieved</strong></DIV></td>
<td width="8%" height="20" class="style4">
<DIV align="center" class="style5"><strong>Month Sales(PY)</strong></DIV></td>
<td width="8%" height="20" class="style4">
<DIV align="center" class="style5"><strong>% Difference</strong></DIV>
<td width="9%" height="20" class="style4">
<DIV align="center" class="style5"><strong>Year to Date Sales</strong></DIV></td>
<td width="9%" height="20" class="style4">
<DIV align="center" class="style5"><strong>Year to Date Sales(PY)</strong></DIV></td>
<td width="9%" height="20" class="style4">
<DIV align="center" class="style5"><strong>% Difference</strong></DIV></td>
</td>
<%
try
{
CRMCon ccon = new CRMCon();
Connection con = ccon.getConnection();
String sql = "SELECT * FROM sp_2('" + data.cmbmonth + "','" + data.cmbyear + "')";
sql += " as (company_code char( 5), branch_code char(15) ," ;
sql += "qouta numeric(19,2) , month_sales numeric(19,2)," ;
sql += "month_sales_py numeric(19,2), year_to_date numeric(19,2), " ;
sql += "year_to_date_py numeric(19,2))" ;
// sql += "ave_daily_sales numeric (19,2)";
//out.println(sql);
Statement st1 = con.createStatement();
ResultSet rs1 = st1.executeQuery(sql);
while (rs1.next())
{
double achieved =0;
if (rs1.getDouble("qouta")==0)
achieved=0;
else
achieved= rs1.getDouble("month_sales") / rs1.getDouble("qouta");
{
double diff =0;
if (rs1.getDouble("month_sales_py")==0)
diff=0;
else
diff= rs1.getDouble("month_sales") / rs1.getDouble("month_sales_py");
{
double difference =0;
if (rs1.getDouble("year_to_date_py")==0)
difference=0;
else
difference= rs1.getDouble("year_to_date") / rs1.getDouble("year_to_date_py");
%>
<tr>
<td width="8%"class="style4"><%= rs1.getString("company_code") %> </td>
<td width="8%"class="style4"><%= rs1.getString("branch_code") %> </td>
<td width="8%"class="style4"><%= rs1.getInt("qouta") %> </td>
<td width="6%"class="style4"><%= rs1.getInt("month_sales") %> </td>
<td width="8%"class="style4"><%= achieved %> </td>
<td width="8%"class="style4"><%= rs1.getInt("month_sales_py") %> </td>
<td width="8%"class="style4"><%= diff %> </td>
<td width="9%"class="style4"><%= rs1.getInt("year_to_date") %> </td>
<td width="8%"class="style4"><%= rs1.getString("year_to_date_py") %> </td>
<td width="8%"class="style4"><%= difference %> </td>
</tr>
<%
}
}
}
}
catch (Exception ex)
{
out.println("Error:"+ex.getMessage());
}
%>
</table>
</b>
</body>
</html>
<%!
class logparameters
{
public String cmbmonth;
public String cmbyear;
}
%>

