SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Member
    Join Date
    Jul 2004
    Location
    MD
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    going crazy - I can submit a form to a new window, but it's ignoring my properties

    I have found lots of variations on the same thing - submitting a form to a new window using window.open so that you can control the window properties. Only it is completely ignoring what I am setting! I get a new window, but it won't remove the toolbar, location bar etc. Going crazy here, please help!

    The script:

    function openWin(wName)
    {
    var params = "left=0,top=0,screenX=0,screenY=0,height=";
    params += (screen.availHeight - 50);
    params += ",width=";
    params += (screen.availWidth - 10);
    params += ",status=1,toolbar=0,scrollbars=1,resizable=1,toolbar=0,location=0,menubar=0";

    popWin = window.open('', wName, params);
    if(popWin.focus) { popWin.focus(); }
    return true;
    }

    The form tag:
    <form name="form2" action="the url goes here" method="post" target="NewWin" onSubmit="return openWin(this.target)">

    The submit button:
    <input type="image" src="../imgs/button_viewmap.gif" alt="Click to view all results" id="button" value="button" align="texttop" onClick="doSubmit(this.form, 'map_all'); return false;">

    The submit code:

    function doSubmit(oForm, flow)
    {
    switch(flow) {
    case 'map':
    oForm.flow.value="map";
    oForm.submit();
    break;
    case 'table':
    oForm.flow.value="table";
    oForm.submit();
    break;
    case 'map_all':
    oForm.flow.value="map_all";
    document.form2.submit();
    break;
    case 'table_all':
    oForm.flow.value="table_all";
    for (i=0; i < form1.project_id.length; i++)
    {
    document.form1.project_id[i].checked = false;
    }
    oForm.submit();
    break;
    }
    }

    (I have 4 different submit buttons that do different things once the page submits to the next page)

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Somewhat convoluted program logic. Form.onsubmit is not called by Form.submit(); the onsubmit event handler is designed to trap user submissions (submit button/image), and you're bypassing it by returning false on the click. The idea seems to be: if you're already programming the form submission, do-it-yourself. Good reason to avoid Form.submit() if possible; the obvious one is: no javascript, no form.

    So the function is ignored, and an ordinary (targetted) window is opened.

    Try this:

    <form name="form2" action="the url goes here" method="post" target="NewWin" onSubmit="return openWin(this, 'map_all')">
    <input type="image" src="../imgs/button_viewmap.gif" alt="Click to view all results" id="button" value="button" align="texttop">
    Code:
    function doSubmit(oForm, flow) 
    {
    switch(flow) {
    ..........
    ..........
    case 'map_all':
    oForm.flow.value="map_all";
    break;
    case 'table_all':
    ..........
    ..........
    }
    
    function openWin(oForm, flow)
    {
    doSubmit(oForm, flow);
    ..........
    popWin = window.open('about&#58;blank', 'NewWin', params);
    if(popWin.focus) { popWin.focus(); }
    return true;
    ...or something like that.
    ::: certified wild guess :::

  3. #3
    SitePoint Member
    Join Date
    Jul 2004
    Location
    MD
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If it bypasses the onsubmit, that would explain it, but your solution will not work - I can't pass the 'map_all' in the form, because that is the value of variable "flow". Flow changes based on which button is pushed, hense why it was sent from the image onclick.




    Quote Originally Posted by adios
    Somewhat convoluted program logic. Form.onsubmit is not called by Form.submit(); the onsubmit event handler is designed to trap user submissions (submit button/image), and you're bypassing it by returning false on the click. The idea seems to be: if you're already programming the form submission, do-it-yourself. Good reason to avoid Form.submit() if possible; the obvious one is: no javascript, no form.

    So the function is ignored, and an ordinary (targetted) window is opened.

    Try this:

    <form name="form2" action="the url goes here" method="post" target="NewWin" onSubmit="return openWin(this, 'map_all')">
    <input type="image" src="../imgs/button_viewmap.gif" alt="Click to view all results" id="button" value="button" align="texttop">
    Code:
    function doSubmit(oForm, flow) 
    {
    switch(flow) {
    ..........
    ..........
    case 'map_all':
    oForm.flow.value="map_all";
    break;
    case 'table_all':
    ..........
    ..........
    }
    
    function openWin(oForm, flow)
    {
    doSubmit(oForm, flow);
    ..........
    popWin = window.open('about:blank', 'NewWin', params);
    if(popWin.focus) { popWin.focus(); }
    return true;
    ...or something like that.

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So just set that 'flow' field from the onclick handler of each button, and leave the window opener assigned to onsubmit. I did say 'something like that'.

    <input type="image" src="../imgs/button_viewmap.gif" alt="Click to view all results" id="button" value="map_all" align="texttop" onclick="flow.value=this.value">
    ::: certified wild guess :::

  5. #5
    SitePoint Member
    Join Date
    Jul 2004
    Location
    MD
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Window is still opening with toolbars etc.... this is nuts!

    function doSubmit(oForm, flow)
    {
    switch(flow) {
    case 'map':
    oForm.flow.value="map";
    oForm.submit();
    break;
    case 'table':
    oForm.flow.value="table";
    oForm.submit();
    break;
    case 'map_all':
    oForm.flow.value="map_all";
    document.form2.submit();
    break;
    case 'table_all':
    oForm.flow.value="table_all";
    for (i=0; i < form1.project_id.length; i++)
    {
    document.form1.project_id[i].checked = false;
    }
    oForm.submit();
    break;
    }
    }

    function openWin(oForm, flow)
    {
    doSubmit(oForm, flow);

    var params = "left=0,top=0,screenX=0,screenY=0,height=";
    params += (screen.availHeight - 50);
    params += ",width=";
    params += (screen.availWidth - 10);
    params += ",status=1,toolbar=0,scrollbars=1,resizable=1,toolbar=0,location=0,menubar=0";

    popWin = window.open('about_:blank', 'MapWin', params);
    if(popWin.focus) { popWin.focus(); }
    return true;

    }


    <input type="image" src="../imgs/button_viewmap.gif" alt="Click to view all results on a map" id="button" value="map_all" align="texttop" onClick="flow.value=this.value"></div></td>

    <form name="form2" action="url goes here" method="post" target="NewWin" onSubmit="return openWin(this.target)">


    Quote Originally Posted by adios
    So just set that 'flow' field from the onclick handler of each button, and leave the window opener assigned to onsubmit. I did say 'something like that'.

    <input type="image" src="../imgs/button_viewmap.gif" alt="Click to view all results" id="button" value="map_all" align="texttop" onclick="flow.value=this.value">

  6. #6
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK....

    <form name="form2" action="url goes here" method="post" target="NewWin" onsubmit="return openWin()">

    <input type="image" src="../imgs/button_viewmap.gif" alt="Click to view all results on a map" id="button" value="map_all" align="texttop" onclick="flow.value=this.value" />

    <input type="text" name="flow" value="" />

    Code:
    function openWin()
    {
    var params = "left=0,top=0,height=";
    params += (screen.availHeight - 50);
    params += ",width=";
    params += (screen.availWidth - 10);
    params += ",status,scrollbars,resizable";
    popWin = window.open('about&#58;blank', 'NewWin', params);
    if(popWin.focus) { popWin.focus(); }
    return true;
    }
    ::: certified wild guess :::

  7. #7
    SitePoint Member
    Join Date
    Jul 2004
    Location
    MD
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't see the difference except that flow is now a text field instead of a javascript variable???

    and you took this.target out of the openwin() call in on submit.

    I'll try, but not sure what this will help....

    going to go beat my head on a rock now...


    Don't make me do it the rediculous way my coworker is doing it - he is opening up a new window first, with a duplicate form from the first page, and using window.opener to get All of the values from the previous page, and repost them on the duplicate page, and Then submits - this just seems like way too much code and a rediculous waste of time... but then so is spending all day on this and getting no where.



    Quote Originally Posted by adios
    OK....

    <form name="form2" action="url goes here" method="post" target="NewWin" onsubmit="return openWin()">

    <input type="image" src="../imgs/button_viewmap.gif" alt="Click to view all results on a map" id="button" value="map_all" align="texttop" onclick="flow.value=this.value" />

    <input type="text" name="flow" value="" />

    Code:
    function openWin()
    {
    var params = "left=0,top=0,height=";
    params += (screen.availHeight - 50);
    params += ",width=";
    params += (screen.availWidth - 10);
    params += ",status,scrollbars,resizable";
    popWin = window.open('about:blank', 'NewWin', params);
    if(popWin.focus) { popWin.focus(); }
    return true;
    }

  8. #8
    SitePoint Member
    Join Date
    Jul 2004
    Location
    MD
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that caused it to open 2 windows - one w/out tool bars but url not found error, and one is my processing page, but it did not go where I wanted it to go which means the form did not actually submit the values to the page.

  9. #9
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is it you need to do? Looks like:

    1) Populate a field based on which submit button was clicked
    2) Open a sized, configured window
    3) Submit the form to it

    Instead of all that rigmarole with switch/case, etc. - this:

    <input type="image" ....value="map_all" onclick="flow.value=this.value" />

    ...will populate a field named "flow" with the string "map_all" when the image is clicked. Variable, shmariable...you're just moving data around. Then call the opener function from onsubmit. The window name (matches the form's target name) is hardcoded. Why pass it in? It's always the same.

    Always choose the shortest distance between two points...form follows function (no pun intended). hth

    [ps: if it still doesn't work, post the exact code you're using here - no placeholders]

    [pps: are you using multiple forms? Aargh...just noticed that. You really need to show what you've got.]
    ::: certified wild guess :::

  10. #10
    SitePoint Member
    Join Date
    Jul 2004
    Location
    MD
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok I'll give you the whole page - to back up, what I"m doing is taking the results from a search and displaying them to the user. They then can do one of 4 things ... click off a bunch of check boxes to view records a) on a map, b) download to excel. Because of issues I've had in the past with too many records being selected and the array created being too long and the page crashing (in pl/sql in a previous site I created) I decided to make a select all option that would by pass the check boxes (just pass on the original search selection from the previous search page, rather than creating an array of selected individual projects). So option 3 is select all to the map, and option 4 is select all to excel. Given the way another programmer created the map page, if I want to select all to the map, I need to send the original search parameters. So for that one option, I create a hidden form while I am processing all of the search parameters into a query string. That form submits directly to the mapper. For the other 3 options, I submit data to a processing page which then either opens the map or opens excel. So that flow variable does 2 things - a) it tells me if I should go straight to the mapper or to my processing page, and b) what i should do when I get to the processing page. There is a form variable called flow, And a javascript variable called flow.

    Here is the whole page minus the html template code to cut down on what you have to read through. I also removed table names, changed field names etc. Dreamweaver created a lot of the query gobbledygook code

    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <%@ include file="../Connections/connect.jsp" %>

    <html>
    <head>
    <title></title>
    <script language="JavaScript">
    function openWin(wName)
    {
    features = "s=1,toolbar=0,scrollbars=1,resizable=1";
    popWin = window.open('', wName, features);
    if(popWin.focus) { popWin.focus(); }
    return true;
    }

    function doSubmit(oForm, flow)
    {
    switch(flow) {
    case 'map':
    oForm.flow.value="map";
    oForm.submit();
    break;
    case 'table':
    oForm.flow.value="table";
    oForm.submit();
    break;
    case 'map_all':
    oForm.flow.value="map_all";
    document.form2.submit();
    break;
    case 'table_all':
    oForm.flow.value="table_all";
    for (i=0; i < form1.id.length; i++)
    {
    document.form1.id[i].checked = false;
    }
    oForm.submit();
    break;
    }
    }

    var i
    function checkBoxes()
    {
    if (form1.checkAll.checked == true)
    {
    for (i=0; i < form1.id.length; i++)
    {
    document.form1.id[i].checked = true;
    }
    }

    if (form1.checkAll.checked == false)
    {
    for (i=0; i < form1.id.length; i++)
    {
    document.form1.id[i].checked = false;
    }
    }
    }

    </script>



    <td width="660">
    <h1 align="center"> Advanced Search Results</h1>
    <p></p> <form name="form2" action="mapper.jsp" method="post" target="newWin" onSubmit="return openWin(this.target)">
    <% //all of the following Java has to be in the body of the html for the hidden form2 to work
    Driver Drivermaindata = (Driver)Class.forName(MM_connect_DRIVER).newInstance();
    Connection Connmaindata = DriverManager.getConnection(MM_connect_STRING,MM_connect_USERNAME,MM_connect_PASSWORD);

    String d_from=" a ";
    String d_where="a.a_flag = 'P' and a.e_flag = 'Y' ";

    String lorderby = "a.name, a.state, a.s, a.s_date, a.type, a.county";
    if (request.getParameter("ORDER_CLAUSE") !=null) {lorderby = (String)request.getParameter("ORDER_CLAUSE");}

    String l_name = "";

    if (!(request.getParameter("name")==null)) { l_name = request.getParameter("name"); }
    if (!(l_project_name.equals(""))) {
    %>
    <input type="hidden" name="name" value="l_name">
    <%
    d_where = d_where + " and upper(a.name) like upper('" + l_name + "')"; }

    String l_state[] = request.getParameterValues("state");

    if (l_state!=null)
    {
    int state_length = l_state.length;

    if (state_length > 0)
    {
    if (!(l_state[0].equals("")))
    {
    if (state_length == 1)
    {
    %>
    <input type="hidden" name="state" value="<%= l_state[0] %>">
    <%
    d_where = d_where + " and a.state like '" + l_state[0] + "'";
    }
    if (state_length > 1)
    { d_where = d_where + " and (";

    for (int i = 0; i < state_length; i++)
    {
    %>
    <input type="hidden" name="state" value="<%= l_state[i] %>">
    <%
    d_where = d_where + "a.state like '" + l_state[i] + "'";
    if (i < (state_length - 1))
    { d_where = d_where + " or " ;

    }
    }
    d_where = d_where + ")";
    }
    }
    }
    }

    String l_county[] = request.getParameterValues("county");

    if (l_county!=null)
    {
    int county_length = l_county.length;

    if (county_length > 0)
    {
    if (!(l_county[0].equals("")))
    {
    if (county_length == 1)
    {
    %>
    <input type="hidden" name="county" value="<%= l_county[0] %>">
    <%
    d_where = d_where + " and a.county like '" + l_county[0] + "'";
    }
    if (county_length > 1)
    { d_where = d_where + " and (";

    for (int i = 0; i < county_length; i++)
    {
    %>
    <input type="hidden" name="county" value="<%= l_county[i] %>">
    <%
    d_where = d_where + "a.county like '" + l_county[i] + "'";
    if (i < (county_length - 1))
    { d_where = d_where + " or " ;

    }
    }
    d_where = d_where + ")";
    }
    }
    }
    }

    String l_region = "";
    if (!(request.getParameter("region")==null)) { l_region = request.getParameter("region"); }
    if (!(l_region.equals(""))) {
    %>
    <input type="hidden" name="caf_region" value="l_region">
    <%
    d_where = d_where + " and upper(a.region) like upper('" + l_region + "')"; }

    String l_dist = "";
    if (!(request.getParameter("dist")==null)) { l_congress = request.getParameter("dist"); }
    if (!(l_dist.equals(""))) {
    %>
    <input type="hidden" name="dist" value="l_dist">
    <%
    d_where = d_where + " and upper(a.dist) like upper('%" + l_dist+ "%')"; }

    String l_hab[] = request.getParameterValues("hab_id");
    String hab_used = "";

    if (l_hab!=null)
    {
    int hab_length = l_hab.length;

    if (hab_length > 0)
    {
    if (!(l_hab[0].equals("")))
    {
    d_from = d_from + ", b ";
    hab_used = "yes";
    if (hab_length == 1)
    {
    %>
    <input type="hidden" name="hab_id" value="<%= l_hab[0] %>">
    <%
    d_where = d_where + " and a.id = b.id and b.hab_id=" + l_hab[0] ;
    }

    if (hab_length > 1)
    { d_where = d_where + " and a.id = b.id and (";

    for (int i = 0; i < hab_length; i++)
    {
    %>
    <input type="hidden" name="hab_id" value="<%= l_hab[i] %>">
    <%
    d_where = d_where + "b.hab_id= " + l_hab[i] ;
    if (i < (hab_length - 1))
    { d_where = d_where + " or " ;

    }
    }
    d_where = d_where + ")";
    }

    }
    }
    }

    String l_tech[] = request.getParameterValues("tech_id");

    if (l_tech!=null)
    {
    int tech_length = l_tech.length;

    if (tech_length > 0)
    {
    if (!(l_tech[0].equals("")))
    {
    if (tech_length == 1)
    {
    try
    {
    int ltech = Integer.parseInt(request.getParameter("tech_id"));
    %>
    <input type="hidden" name="tech_id" value="<%= l_tech[0] %>">
    <%
    d_from = d_from + ", c ";
    d_where = d_where + " and a.id = c.id and c.tech_id=" + l_tech[0] ;
    }

    catch(Exception e)
    {
    String lcat = request.getParameter("tech_id");
    %>
    <input type="hidden" name="tech_id" value="<%= l_tech[0] %>">
    <%
    d_from = d_from + ", c, d ";
    d_where = d_where + " and a.id = c.id and c.tech_id = d.tech_id and d.cat='" + l_tech[0] +"'";
    }
    }

    if (tech_length > 1)
    {
    d_from = d_from + ", c, d ";
    d_where = d_where + " and a.id = c.id and c.id = d.id and (";
    for (int i = 0; i < tech_length; i++)
    {
    try
    {
    %>
    <input type="hidden" name="tech_id" value="<%= l_tech[i] %>">
    <%
    int ltech = Integer.parseInt(l_tech[i]);
    d_where = d_where + " c.tech_id=" + l_tech[i] ;
    }

    catch(Exception e)
    {
    %>
    <input type="hidden" name="tech_id" value="<%= l_tech[i] %>">
    <%
    String lcat = l_tech[i];
    d_where = d_where + " d.cat='" + l_tech[i] + "'" ;
    }
    if (i < (tech_length - 1))
    { d_where = d_where + " or " ;
    }
    }
    d_where = d_where + ")";
    }
    }
    }
    }

    String l_mon[] = request.getParameterValues("mon_id");

    if (l_mon!=null)
    {
    int mon_length = l_mon.length;

    if (mon_length > 0)
    {
    if (!(l_mon[0].equals("")))
    {
    if (mon_length == 1)
    {
    try
    {
    %>
    <input type="hidden" name="mon_id" value="<%= l_mon[0] %>">
    <%
    int lmon = Integer.parseInt(request.getParameter("mon_id"));
    d_from = d_from + ", tbl_mon_link e ";
    d_where = d_where + " and a.id = e.id and e.mon_id=" + l_mon[0] ;
    }

    catch(Exception e)
    {
    %>
    <input type="hidden" name="mon_id" value="<%= l_mon[0] %>">
    <%
    String lcat = request.getParameter("mon_id");
    d_from = d_from + ", tbl_mon_link e, tbl_pick_mon f ";
    d_where = d_where + " and a.id = e.id and e.mon_id = f.mon_id and f.cat='" + l_mon[0] +"'";
    }
    }

    if (mon_length > 1)
    {
    d_from = d_from + ", tbl_mon_link e, tbl_pick_mon f ";
    d_where = d_where + " and a.id = e.id and e.mon_id = f.mon_id and (";
    for (int i = 0; i < mon_length; i++)
    {
    try
    {
    %>
    <input type="hidden" name="mon_id" value="<%= l_mon[i] %>">
    <%
    int lmon = Integer.parseInt(l_mon[i]);
    d_where = d_where + " e.mon_id=" + l_mon[i] ;
    }

    catch(Exception e)
    {
    %>
    <input type="hidden" name="mon_id" value="<%= l_mon[i] %>">
    <%
    String lcat = l_mon[i];
    d_where = d_where + " f.cat='" + l_mon[i] + "'" ;
    }
    if (i < (mon_length - 1))
    { d_where = d_where + " or " ;
    }
    }
    d_where = d_where + ")";
    }
    }
    }
    }

    String l_ben[] = request.getParameterValues("g_id");

    if (l_ben!=null)
    {
    int ben_length = l_ben.length;

    if (ben_length > 0)
    {
    if (!(l_ben[0].equals("")))
    {
    d_from = d_from + ", g ";
    if (ben_length == 1)
    {
    %>
    <input type="hidden" name="g_id" value="<%= l_ben[0] %>">
    <%
    d_where = d_where + " and a.id = g.id and g.g_id=" + l_ben[0] ;
    }

    if (ben_length > 1)
    { d_where = d_where + " and a.id = g.id and (";

    for (int i = 0; i < ben_length; i++)
    {
    %>
    <input type="hidden" name="g_id" value="<%= l_ben[i] %>">
    <%
    d_where = d_where + "g.g_id= " + l_ben[i] ;
    if (i < (ben_length - 1))
    { d_where = d_where + " or " ;

    }
    }
    d_where = d_where + ")";
    }
    }
    }
    }

    String l_p[] = request.getParameterValues("p_id");

    if (l_p!=null)
    {
    int p_length = l_p.length;

    if (p_length > 0)
    {
    if (!(l_p[0].equals("")))
    {
    d_from = d_from + ", h ";
    if (p_length == 1)
    {
    %>
    <input type="hidden" name="p_id" value="<%= l_p[0] %>">
    <%
    d_where = d_where + " and a.id = h.id and h.p_id=" + l_p[0] ;
    }

    if (p_length > 1)
    { d_where = d_where + " and a.id = h.id and (";

    for (int i = 0; i < p_length; i++)
    {
    %>
    <input type="hidden" name="p_id" value="<%= l_p[i] %>">
    <%
    d_where = d_where + "h.p_id= " + l_p[i] ;
    if (i < (p_length - 1))
    { d_where = d_where + " or " ;

    }
    }
    d_where = d_where + ")";
    }
    }
    }
    }

    String l_s[] = request.getParameterValues("s");
    int s_length;
    if (l_s!=null)
    {
    s_length = l_s.length;

    if (s_length > 0)
    {
    if (!(l_s[0].equals("")))
    {
    if (s_length == 1)
    {
    %>
    <input type="hidden" name="s" value="<%= l_s[0] %>">
    <%
    d_where = d_where + " and a.s like '" + l_s[0] + "'" ;
    }

    if (s_length > 1)
    { d_where = d_where + " and (";

    for (int i = 0; i < s_length; i++)
    {
    %>
    <input type="hidden" name="s" value="<%= l_s[i] %>">
    <%
    d_where = d_where + "a.s = '" + l_s[i] + "'";
    if (i < (s_length - 1))
    { d_where = d_where + " or " ;

    }
    }
    d_where = d_where + ")";
    }
    }
    }
    }

    String l_size = "";
    String lgroupby = "";
    String lhaving = "";

    if (!(request.getParameter("e_a")==null)) { l_size = request.getParameter("e_a"); }
    if (!(l_size.equals("")))
    { %>
    <input type="hidden" name="e_a" value="l_size">
    <%
    if (!(hab_used.equals("yes")))
    {d_from = d_from + ", b";
    d_where = d_where + " and a.id = b.id";}
    if (l_size.equals("0-1"))
    { lhaving = "HAVING SUM(b.E_A)<=1";
    lgroupby = "GROUP BY a.id, a.name, a.state, a.s, a.s_date, a.type, a.county";
    }
    if (l_size.equals("1-5"))
    { lhaving = "HAVING (SUM(b.E_A)>1 and SUM(b.e_a)<=5)";
    lgroupby = "GROUP BY a.id, a.name, a.state, a.s, s_date, a.type, a.county";
    }
    if (l_size.equals("5-10"))
    { lhaving = "HAVING (SUM(b.E_A)>5 and SUM(b.e_a)<=10)";
    lgroupby = "GROUP BY a.id, a.name, a.state, a.s, s_date, a.type, a.county";
    }
    if (l_size.equals("10-50"))
    { lhaving = "HAVING (SUM(b.E_A)>10 and SUM(b.e_a)<=50)";
    lgroupby = "GROUP BY a.id, a.name, a.state, a.s, s_date, a.type, a.county";
    }
    if (l_size.equals("50-100"))
    { lhaving = "HAVING (SUM(b.E_A)>50 and SUM(b.e_a)<=100)";
    lgroupby = "GROUP BY a.id, a.name, a.state, a.s, s_date, a.type, a.county";
    }
    if (l_size.equals("100"))
    { lhaving = "HAVING SUM(b.E_A)>100";
    lgroupby = "GROUP BY a.id, a.name, a.state, a.s, s_date, a.type, a.county";
    }
    }

    String l_year = "";

    if (!(request.getParameter("s_date")==null)) { l_year = request.getParameter("s_date"); }
    if (!(l_year.equals(""))) { %>
    <input type="hidden" name="s_date" value="l_year">
    <%
    d_where = d_where + " and to_char(a.s_date, 'YYYY') like '" + l_year + "'"; }


    String l_db[] = request.getParameterValues("db_id");
    int db_length;
    if (l_db!=null)
    {
    db_length = l_db.length;

    if (db_length > 0)
    {
    if (!(l_db[0].equals("")))
    {
    d_from = d_from + ", i ";
    if (db_length == 1)
    {
    %>
    <input type="hidden" name="db_id" value="<%= l_db[0] %>">
    <%
    d_where = d_where + " and a.id = i.id and i.db_id=" + l_db[0] ;
    }

    if (db_length > 1)
    { d_where = d_where + " and a.id = i.id and (";

    for (int i = 0; i < db_length; i++)
    { %>
    <input type="hidden" name="db_id" value="<%= l_db[i] %>">
    <%
    d_where = d_where + "i.db_id= " + l_db[i] ;
    if (i < (db_length - 1))
    { d_where = d_where + " or " ;

    }
    }
    d_where = d_where + ")";
    }
    }
    }
    }
    %>
    </form>
    <%
    String query = "";
    String query2 = "";
    if (!(request.getParameter("query1")==null)) { query2 = request.getParameter("query1"); }

    if (query2.equals(""))
    {
    query="SELECT a.id, a.name, a.state, a.s, to_char(a.s_date, 'YYYY') s_date, a.type, a.county FROM " + d_from + " WHERE " + d_where ;
    if (!(lhaving.equals(""))) {query = query + " " + lhaving;}
    if (!(lgroupby.equals(""))) {query = query + " " + lgroupby;}
    }

    else
    {query = query2;}

    String query1 = query;
    query = query + " order by " + lorderby;

    PreparedStatement Statementmaindata = Connmaindata.prepareStatement(query);
    ResultSet maindata = Statementmaindata.executeQuery();
    boolean maindata_isEmpty = !maindata.next();
    boolean maindata_hasData = !maindata_isEmpty;
    Object maindata_data;
    int maindata_numRows = 0;
    %>
    <%
    int Repeat1__numRows = -1;
    int Repeat1__index = 0;
    maindata_numRows += Repeat1__numRows;
    %>
    <%
    // *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

    int maindata_first = 1;
    int maindata_last = 1;
    int maindata_total = -1;

    if (maindata_isEmpty) {
    maindata_total = maindata_first = maindata_last = 0;
    }

    //set the number of rows displayed on this page
    if (maindata_numRows == 0) {
    maindata_numRows = 1;
    }
    %> <%
    // *** Recordset Stats: if we don't know the record count, manually count them

    if (maindata_total == -1) {

    // count the total records by iterating through the recordset
    for (maindata_total = 1; maindata.next(); maindata_total++);

    // reset the cursor to the beginning
    maindata.close();
    maindata = Statementmaindata.executeQuery();
    maindata_hasData = maindata.next();

    // set the number of rows displayed on this page
    if (maindata_numRows < 0 || maindata_numRows > maindata_total) {
    maindata_numRows = maindata_total;
    }

    // set the first and last displayed record
    maindata_first = Math.min(maindata_first, maindata_total);
    maindata_last = Math.min(maindata_first + maindata_numRows - 1, maindata_total);
    }
    %> <% String MM_paramName = ""; %> <%
    // *** Move To Record and Go To Record: declare variables

    ResultSet MM_rs = maindata;
    int MM_rsCount = maindata_total;
    int MM_size = maindata_numRows;
    String MM_uniqueCol = "";
    MM_paramName = "";
    int MM_offset = 0;
    boolean MM_atTotal = false;
    boolean MM_paramIsDefined = (MM_paramName.length() != 0 && request.getParameter(MM_paramName) != null);
    %> <%
    // *** Move To Record: handle 'index' or 'offset' parameter

    if (!MM_paramIsDefined && MM_rsCount != 0) {

    //use index parameter if defined, otherwise use offset parameter
    String r = request.getParameter("index");
    if (r==null) r = request.getParameter("offset");
    if (r!=null) MM_offset = Integer.parseInt(r);

    // if we have a record count, check if we are past the end of the recordset
    if (MM_rsCount != -1) {
    if (MM_offset >= MM_rsCount || MM_offset == -1) { // past end or move last
    if (MM_rsCount % MM_size != 0) // last page not a full repeat region
    MM_offset = MM_rsCount - MM_rsCount % MM_size;
    else
    MM_offset = MM_rsCount - MM_size;
    }
    }

    //move the cursor to the selected record
    int i;
    for (i=0; maindata_hasData && (i < MM_offset || MM_offset == -1); i++) {
    maindata_hasData = MM_rs.next();
    }
    if (!maindata_hasData) MM_offset = i; // set MM_offset to the last possible record
    }
    %> <%
    // *** Move To Record: if we dont know the record count, check the display range

    if (MM_rsCount == -1) {

    // walk to the end of the display range for this page
    int i;
    for (i=MM_offset; maindata_hasData && (MM_size < 0 || i < MM_offset + MM_size); i++) {
    maindata_hasData = MM_rs.next();
    }

    // if we walked off the end of the recordset, set MM_rsCount and MM_size
    if (!maindata_hasData) {
    MM_rsCount = i;
    if (MM_size < 0 || MM_size > MM_rsCount) MM_size = MM_rsCount;
    }

    // if we walked off the end, set the offset based on page size
    if (!maindata_hasData && !MM_paramIsDefined) {
    if (MM_offset > MM_rsCount - MM_size || MM_offset == -1) { //check if past end or last
    if (MM_rsCount % MM_size != 0) //last page has less records than MM_size
    MM_offset = MM_rsCount - MM_rsCount % MM_size;
    else
    MM_offset = MM_rsCount - MM_size;
    }
    }

    // reset the cursor to the beginning
    maindata.close();
    maindata = Statementmaindata.executeQuery();
    maindata_hasData = maindata.next();
    MM_rs = maindata;

    // move the cursor to the selected record
    for (i=0; maindata_hasData && i < MM_offset; i++) {
    maindata_hasData = MM_rs.next();
    }
    }
    %> <%
    // *** Move To Record: update recordset stats

    // set the first and last displayed record
    maindata_first = MM_offset + 1;
    maindata_last = MM_offset + MM_size;
    if (MM_rsCount != -1) {
    maindata_first = Math.min(maindata_first, MM_rsCount);
    maindata_last = Math.min(maindata_last, MM_rsCount);
    }

    // set the boolean used by hide region to check if we are on the last record
    MM_atTotal = (MM_rsCount != -1 && MM_offset + MM_size >= MM_rsCount);
    %> <%
    // *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

    String MM_keepBoth,MM_keepURL="",MM_keepForm="",MM_keepNone="";
    String[] MM_removeList = { "index", MM_paramName };

    // create the MM_keepURL string
    if (request.getQueryString() != null) {
    MM_keepURL = '&' + request.getQueryString();
    for (int i=0; i < MM_removeList.length && MM_removeList[i].length() != 0; i++) {
    int start = MM_keepURL.indexOf(MM_removeList[i]) - 1;
    if (start >= 0 && MM_keepURL.charAt(start) == '&' &&
    MM_keepURL.charAt(start + MM_removeList[i].length() + 1) == '=') {
    int stop = MM_keepURL.indexOf('&', start + 1);
    if (stop == -1) stop = MM_keepURL.length();
    MM_keepURL = MM_keepURL.substring(0,start) + MM_keepURL.substring(stop);
    }
    }
    }

    // add the Form variables to the MM_keepForm string
    if (request.getParameterNames().hasMoreElements()) {
    java.util.Enumeration items = request.getParameterNames();
    while (items.hasMoreElements()) {
    String nextItem = (String)items.nextElement();
    boolean found = false;
    for (int i=0; !found && i < MM_removeList.length; i++) {
    if (MM_removeList[i].equals(nextItem)) found = true;
    }
    if (!found && MM_keepURL.indexOf('&' + nextItem + '=') == -1) {
    MM_keepForm = MM_keepForm + '&' + nextItem + '=' + java.net.URLEncoder.encode(request.getParameter(nextItem));
    }
    }
    }

    // create the Form + URL string and remove the intial '&' from each of the strings
    MM_keepBoth = MM_keepURL + MM_keepForm;
    if (MM_keepBoth.length() > 0) MM_keepBoth = MM_keepBoth.substring(1);
    if (MM_keepURL.length() > 0) MM_keepURL = MM_keepURL.substring(1);
    if (MM_keepForm.length() > 0) MM_keepForm = MM_keepForm.substring(1);
    %> <%
    // *** Move To Record: set the strings for the first, last, next, and previous links

    String MM_moveFirst,MM_moveLast,MM_moveNext,MM_movePrev;
    {
    String MM_keepMove = MM_keepBoth; // keep both Form and URL parameters for moves
    String MM_moveParam = "index=";

    // if the page has a repeated region, remove 'offset' from the maintained parameters
    if (MM_size > 1) {
    MM_moveParam = "offset=";
    int start = MM_keepMove.indexOf(MM_moveParam);
    if (start != -1 && (start == 0 || MM_keepMove.charAt(start-1) == '&')) {
    int stop = MM_keepMove.indexOf('&', start);
    if (start == 0 && stop != -1) stop++;
    if (stop == -1) stop = MM_keepMove.length();
    if (start > 0) start--;
    MM_keepMove = MM_keepMove.substring(0,start) + MM_keepMove.substring(stop);
    }
    }

    // set the strings for the move to links
    StringBuffer urlStr = new StringBuffer(request.getRequestURI()).append('?').append(MM_keepMove);
    if (MM_keepMove.length() > 0) urlStr.append('&');
    urlStr.append(MM_moveParam);
    MM_moveFirst = urlStr + "0";
    MM_moveLast = urlStr + "-1";
    MM_moveNext = urlStr + Integer.toString(MM_offset+MM_size);
    MM_movePrev = urlStr + Integer.toString(Math.max(MM_offset-MM_size,0));
    }
    %> <p>Clicking on the project name will take
    you to a project profile for that project, while clicking on &quot;Full
    Report&quot; will allow you to view all data entered for that project.
    </p>

    <p>To view selected projects on a map or download projects to a spreadsheet
    file, check the boxes adjacent to the project(s) you wish to see and select
    the &quot;View Map&quot; or &quot;Download Table&quot; buttons below the table.
    To select all projects, use the Select All features below the table. </p>
    <div align="center">
    <h4>-- <%=(maindata_total)%> Records Found --</h4>
    </div>
    <form name="form1" action="process.jsp" method="post" target="newWin" onSubmit="return openWin(this.target)">
    <table width="639" border="0" cellspacing="0" cellpadding="0">
    <tr class="smallText">
    <td width="1" bgcolor="#339966"><img src="../imgs/spacer.gif" alt="" width="1" height="8"></td>
    <td width="5" bgcolor="#339966"><img src="../imgs/spacer.gif" alt="" width="5" height="25"></td>
    <td width="10" bgcolor="#339966"><input type="checkbox" name="checkAll" onClick="checkBoxes()">
    </td>
    <td width="1" bgcolor="#339966"><img src="../imgs/spacer.gif" alt="" width="1" height="8"></td>
    <td width="5" bgcolor="#339966"><img src="../imgs/spacer.gif" alt="" width="5" height="25"></td>
    <td width="200" bgcolor="#339966"><a href="results.jsp?query1=<%= query1 %>&ORDER_CLAUSE=a.name,%20a.state,%20a.s,%20s_date,%20a.type,%20a.county" class="headerLinkText">Name</a></td>
    <td width="1" bgcolor="#339966"><img src="../imgs/spacer.gif" alt="" width="1" height="8"></td>
    <td width="5" bgcolor="#339966"><img src="../imgs/spacer.gif" alt="" width="5" height="25"></td>
    <td width="30" bgcolor="#339966"><a href="results.jsp?query1=<%= query1 %>&ORDER_CLAUSE=a.state,%20a.name,%20a.project_s,%20s_date,%20a.type,%20a.county" class="headerLinkText">State</a></td>
    <td width="1" bgcolor="#339966"><img src="../imgs/spacer.gif" alt="" width="1" height="8"></td>
    <td width="5" bgcolor="#339966"><img src="../imgs/spacer.gif" alt="" width="5" height="25"></td>
    <td width="75" bgcolor="#339966"><a href="results.jsp?query1=<%= query1 %>&ORDER_CLAUSE=a.county,%20a.name,%20a.state,%20s_date,%20a.type,%20a.project_s" class="headerLinkText">County</a></td>
    <td width="1" bgcolor="#339966"><img src="../imgs/spacer.gif" alt="" width="1" height="8"></td>
    <td width="5" bgcolor="#339966"><img src="../imgs/spacer.gif" alt="" width="5" height="25"></td>
    <td width="50" bgcolor="#339966"><a href="results.jsp?query1=<%= query1 %>&ORDER_CLAUSE=a.project_s,%20a.name,%20a.state,%20s_date,%20a.type,%20a.county" class="headerLinkText">s</a></td>
    <td width="1" bgcolor="#339966"><img src="../imgs/spacer.gif" alt="" width="1" height="8"></td>
    <td width="5" bgcolor="#339966"><img src="../imgs/spacer.gif" alt="" width="5" height="25"></td>
    <td width="100" bgcolor="#339966"><font color="#FFFFFF"><strong>Hab<br>
    Types<br>
    Restored</strong></font></td>
    <td width="1" bgcolor="#339966"><img src="../imgs/spacer.gif" alt="" width="1" height="8"></td>
    <td width="5" bgcolor="#339966"><img src="../imgs/spacer.gif" alt="" width="5" height="25"></td>
    <td width="40" bgcolor="#339966"><a href="results.jsp?query1=<%= query1 %>&ORDER_CLAUSE=s_date,%20a.name,%20a.state,%20a.project_s,%20a.type,%20a.county" class="headerLinkText">Year<br>
    Imple-<br>
    mented</a></td>
    <td width="1" bgcolor="#339966"><img src="../imgs/spacer.gif" alt="" width="1" height="8"></td>
    <td width="5" bgcolor="#339966"><img src="../imgs/spacer.gif" alt="" width="5" height="25"></td>
    <td width="75" bgcolor="#339966"><font color="#FFFFFF"><strong><br>
    Funded?</strong></font></td>
    <td width="1" bgcolor="#339966"><img src="../imgs/spacer.gif" alt="" width="1" height="8"></td>
    <td width="5" bgcolor="#339966"><img src="../imgs/spacer.gif" alt="" width="5" height="25"></td>
    <td width="50" bgcolor="#339966"><font color="#FFFFFF"><strong>Link</strong></font></td>
    </tr>
    <% while ((maindata_hasData)&&(Repeat1__numRows-- != 0))
    {
    int nProjectID = maindata.getInt("id");
    String sHabitatType = "";
    PreparedStatement StatementRecordset1 = Connmaindata.prepareStatement("select b.H_Type from a, b where (a.id=" + nPID + ") and (a.hab_id=b.hab_id) and (a.A_FLAG='P')order by b.Hab_Type");
    try
    {
    ResultSet rs = StatementRecordset1.executeQuery();
    while(rs.next())
    {
    if(rs.getString("Hab_Type")!=null)
    {
    if(!"".equals(sHabType))
    sHabType += ", ";
    sHabType += rs.getString("Hab_Type");
    }
    }
    rs.close();
    StatementRecordset1.close();
    }
    catch(Exception e)
    {
    sHabType = "";
    }

    String nProject_type = maindata.getString("type");
    String sFunded = "";

    if (nProject_type.equals("Funded"))
    {sFunded = "Yes";}

    if (!(nProject_type.equals("Funded")))
    {sFunded = "No";}

    %>
    <tr class="smallText">
    <td width="1" bgcolor="#999999"><img src="/imgs/spacer.gif" alt="" width="1" height="1"></td>
    <td width="5" bgcolor="#ffffff"><img src="/imgs/spacer.gif" alt="" width="5" height="25"></td>
    <td> <input name="id" type="checkbox" value="<%=(((maindata_data = maindata.getObject("id"))==null || maindata.wasNull())?"":maindata_data)%>"></td>
    <td width="1" bgcolor="#999999"><img src="/imgs/spacer.gif" alt="" width="1" height="1"></td>
    <td width="5" bgcolor="#ffffff"><img src="/imgs/spacer.gif" alt="" width="5" height="25"></td>
    <td><a href="dynamic.jsp?id=<%=(((maindata_data = maindata.getObject("id"))==null || maindata.wasNull())?"":maindata_data)%>"><%=(((maindata_data = maindata.getObject("name"))==null || maindata.wasNull())?"":maindata_data)%></a></td>
    <td width="1" bgcolor="#999999"><img src="/imgs/spacer.gif" alt="" width="1" height="1"></td>
    <td width="5" bgcolor="#ffffff"><img src="/imgs/spacer.gif" alt="" width="5" height="25"></td>
    <td><%=(((maindata_data = maindata.getObject("state"))==null || maindata.wasNull())?"":maindata_data)%></td>
    <td width="1" bgcolor="#999999"><img src="/imgs/spacer.gif" alt="" width="1" height="1"></td>
    <td width="5" bgcolor="#ffffff"><img src="/imgs/spacer.gif" alt="" width="5" height="25"></td>
    <td><%=(((maindata_data = maindata.getObject("COUNTY"))==null || maindata.wasNull())?"":maindata_data)%></td>
    <td width="1" bgcolor="#999999"><img src="/imgs/spacer.gif" alt="" width="1" height="1"></td>
    <td width="5" bgcolor="#ffffff"><img src="/imgs/spacer.gif" alt="" width="5" height="25"></td>
    <td><%=(((maindata_data = maindata.getObject("s"))==null || maindata.wasNull())?"":maindata_data)%></td>
    <td width="1" bgcolor="#999999"><img src="/imgs/spacer.gif" alt="" width="1" height="1"></td>
    <td width="5" bgcolor="#ffffff"><img src="/imgs/spacer.gif" alt="" width="5" height="25"></td>
    <td><%= sHabType %></td>
    <td width="1" bgcolor="#999999"><img src="/imgs/spacer.gif" alt="" width="1" height="1"></td>
    <td width="5" bgcolor="#ffffff"><img src="/imgs/spacer.gif" alt="" width="5" height="25"></td>
    <td><%=(((maindata_data = maindata.getObject("s_date"))==null || maindata.wasNull())?"":maindata_data)%></td>
    <td width="1" bgcolor="#999999"><img src="/imgs/spacer.gif" alt="" width="1" height="1"></td>
    <td width="5" bgcolor="#ffffff"><img src="/imgs/spacer.gif" alt="" width="5" height="25"></td>
    <td><%= sFunded %></td>
    <td width="1" bgcolor="#999999"><img src="/imgs/spacer.gif" alt="" width="1" height="1"></td>
    <td width="5" bgcolor="#ffffff"><img src="/imgs/spacer.gif" alt="" width="5" height="25"></td>
    <td><a href="view_project.jsp?id=<%=(((maindata_data = maindata.getObject("id"))==null || maindata.wasNull())?"":maindata_data)%>">Full
    Report</a></td>
    <td width="1" bgcolor="#999999"><img src="/imgs/spacer.gif" alt="" width="1" height="1"></td>
    <td width="5" bgcolor="#ffffff"><img src="/imgs/spacer.gif" alt="" width="5" height="25"></td>
    </tr>
    <tr>
    <td colspan="28" bgcolor="#999999"><img src="../imgs/spacer.gif" alt="" width="1" height="1"></td>
    </tr>
    <%
    Repeat1__index++;
    maindata_hasData = maindata.next();
    }
    %>
    </table>
    <div align="center">
    <h4><br>
    -- <%=(maindata_total)%> Records Found --</h4>
    </div>
    <input type="hidden" name="flow" value="">
    <input type="hidden" name="querystring" value="<%= query%>">
    <table align="center" width="600" border="1" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC" bgcolor="#CCCCCC">
    <tr bordercolor="#CCCCCC" bgcolor="#CCCCCC">
    <td> <div align="center">For <span class="fieldname">SELECTED</span>
    Projects/div></td>
    <td bgcolor="#CCCCCC" class="phraseText"> <div align="center"></div></td>
    <td> <div align="center">For <span class="fieldname">ALL</span> Projects/div></td>
    </tr>
    <tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
    <td width="184"> <div align="center">
    <input type="image" src="../imgs/button_viewmap.gif" alt="Click to view selected results on a map" id="button" value="button" align="texttop" onClick="doSubmit(this.form, 'map'); return false;">
    </div></td>
    <td width="259"> <div align="center">Displays projects on an interactive
    map that links to project profiles.</div></td>
    <td width="155"> <div align="center">
    <input type="image" src="../imgs/button_viewmap.gif" alt="Click to view all results on a map" id="button" value="button" align="texttop" onClick="doSubmit(this.form, 'map_all'); return false;">
    </div></td>
    </tr>
    <tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
    <td> <div align="center">OR </div></td>
    <td> <div align="center"><font color="#FFFFFF">.</font></div></td>
    <td> <div align="center">OR</div></td>
    </tr>
    <tr bordercolor="#FFFFFF" bgcolor="#FFFFFF">
    <td> <div align="center">
    <input type="image" src="../imgs/button_downloadtable.gif" alt="Click to view selected results on a map" id="button" value="button" align="texttop" onClick="doSubmit(this.form, 'table'); return false;">
    </div></td>
    <td> <div align="center">Saves projects in a spreadsheet file format.</div></td>
    <td> <div align="center">
    <input type="image" src="../imgs/button_downloadtable.gif" alt="Click to view selected results on a map" id="button" value="button" align="texttop" onClick="doSubmit(this.form, 'table_all'); return false;">
    </div></td>
    </tr>
    </table>


    </form>

    </body>
    </html>
    <%
    maindata.close();
    Statementmaindata.close();
    Connmaindata.close();
    %>

  11. #11
    SitePoint Member
    Join Date
    Jul 2004
    Location
    MD
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Adios - did I scare you away?

  12. #12
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    <%
    d_where = d_where + " and upper(a.region) like upper('" + l_region + "')"; }

    String l_dist = "";
    if (!(request.getParameter("dist")==null)) { l_congress = request.getParameter("dist"); }
    if (!(l_dist.equals(""))) {
    %>
    <input type="hidden" name="dist" value="l_dist">
    <%
    d_where = d_where + " and upper(a.dist) like upper('%" + l_dist+ "%')"; }<%
    d_where = d_where + " and upper(a.region) like upper('" + l_region + "')"; }

    String l_dist = "";
    if (!(request.getParameter("dist")==null)) { l_congress = request.getParameter("dist"); }
    if (!(l_dist.equals(""))) {
    %>
    <input type="hidden" name="dist" value="l_dist">
    <%
    d_where = d_where + " and upper(a.dist) like upper('%" + l_dist+ "%')"; }<%
    d_where = d_where + " and upper(a.region) like upper('" + l_region + "')"; }

    String l_dist = "";
    if (!(request.getParameter("dist")==null)) { l_congress = request.getParameter("dist"); }
    if (!(l_dist.equals(""))) {
    %>
    <input type="hidden" name="dist" value="l_dist">
    <%
    d_where = d_where + " and upper(a.dist) like upper('%" + l_dist+ "%')"; }
    <%
    d_where = d_where + " and upper(a.region) like upper('" + l_region + "')"; }

    String l_dist = "";
    if (!(request.getParameter("dist")==null)) { l_congress = request.getParameter("dist"); }
    if (!(l_dist.equals(""))) {
    %>
    <input type="hidden" name="dist" value="l_dist">
    <%
    d_where = d_where + " and upper(a.dist) like upper('%" + l_dist+ "%')"; }

    String l_hab[] = request.getParameterValues("hab_id");
    String hab_used = "";
    ....................................................................................
    if (l_hab!=null)
    {
    int hab_length = l_hab.length;

    if (hab_length > 0)
    {
    if (!(l_hab[0].equals("")))
    {
    d_from = d_from + ", b ";
    hab_used = "yes";
    if (hab_length == 1)
    {
    %>
    <input type="hidden" name="hab_id" value="<%= l_hab[0] %>">
    <%
    d_where = d_where + " and a.id = b.id and b.hab_id=" + l_hab[0] ;
    if (hab_length > 0)
    {
    if (!(l_hab[0].equals("")))
    {
    d_from = d_from + ", b ";
    hab_used = "yes";
    if (hab_length == 1)
    {
    %>
    <input type="hidden" name="hab_id" value="<%= l_hab[0] %>">
    <%
    d_where = d_where + " and a.id = b.id and b.hab_id=" + l_hab[0] ; if (hab_length > 0)
    {
    if (!(l_hab[0].equals("")))
    {
    d_from = d_from + ", b ";
    hab_used = "yes";
    if (hab_length == 1)
    {
    %>
    <input type="hidden" name="hab_id" value="<%= l_hab[0] %>">
    <%
    d_where = d_where + " and a.id = b.id and b.hab_id=" + l_hab[0] ; if (hab_length > 0)
    {
    if (!(l_hab[0].equals("")))
    {
    d_from = d_from + ", b ";
    hab_used = "yes";
    if (hab_length == 1)
    {
    %>
    <input type="hidden" name="hab_id" value="<%= l_hab[0] %>">
    <%
    d_where = d_where + " and a.id = b.id and b.hab_id=" + l_hab[0] ; if (hab_length > 0)
    {
    if (!(l_hab[0].equals("")))
    {
    d_from = d_from + ", b ";
    hab_used = "yes";
    if (hab_length == 1)
    {
    %>
    <input type="hidden" name="hab_id" value="<%= l_hab[0] %>">
    <%
    d_where = d_where + " and a.id = b.id and b.hab_id=" + l_hab[0] ;
    ::: certified wild guess :::

  13. #13
    SitePoint Member
    Join Date
    Jul 2004
    Location
    MD
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You said you wanted all of the code!!!

    All of that bazillion lines of code is to build a custom query string based on parameters sent from a search page before. If I don't do all of that, then the alternative is to build a giant query from the get-go, joining 10 tables or so, bogging down the system, when the user may only want to search on one field. (There are like 15 options for them to search on)

    Ignore all of that - that was to show you what I'm doing.

    Do you not have an answer?

    Looks like I will have to do it the long way my coworker is... which I think is retarded - there has to be a better way.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •