Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combobox value returns "Null"

    Hi friends,

    I want to display a field value in combo box from database.
    But the result, it returns me null in combo box, even in textbox also..

    Plz help me in this regard.
    Advance thanks to u all.

    Code:
    <%@ page import="java.sql.*" %>
    <% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); %>
    <HTML>
        <HEAD>
            <TITLE>Database</TITLE>
        </HEAD>
    
        <BODY>
            <H1>Database</H1>
            <% 
                Connection connection = DriverManager.getConnection("jdbc:odbc:emaildb", "", "");
                Statement statement = connection.createStatement();
                String Cname = request.getParameter("CompName");
                 String Fy = request.getParameter("FYear");
                  String Qtr = request.getParameter("Quarter");
                   String QtrAm = request.getParameter("QtrAmt");  
              ResultSet resultset = statement.executeQuery("select CompanyName, sum(ForQtr)as Tota from Imports group by CompanyName") ;
                     
              
                if(!resultset.next()) {
                out.println("Sorry, could not find that CompInfo. ");
                } else {
            %>
            	<TABLE BORDER="1">
                <TR>
                  
               <!--<TH>Financial Year</TH>
               <TH>Sum of Quarters</TH>-->
               </TR>
                <% String AB=request.getParameter("CompanyName");%>
         		<input type="text" value="<%=AB%>">   
               
               <select>
               <%
               while(resultset.next()) {
               String ABC=request.getParameter("CompanyName");
                out.print("<option>"+ABC+"</option>");
               
               %>
               </select>
               <TR>
                   <TD> <%= resultset.getString(1) %> </TD>
                   <TD> <%= resultset.getString(2) %> </TD>
                  
              </TR>
          
           <%}%>
                        
           </TABLE>
              
           
           <BR>
          
               
           <% 
               } 
           %>
        </BODY>
    </HTML>
    regards
    raja

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    you need to name ur form elements otherwise how can the application server distinguish one textbox from another? same goes for the selects too...
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow


  •  

    Tags for this Thread

    Posting Permissions

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