#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    12
    Rep Power
    0

    Question How to retrieve a specific data from a table using jsp


    Can anyone pls figure out the problem with these codes?

    This code retrieves the journal names from the database in a dropdown menu:
    <SELECT NAME="name" ID="name">
    <%include file=showJournal.jsp%>
    </SELECT>


    in showJournal.jsp:

    String Query="SELECT DISTINCT name FROM journal";

    //get result
    ResultSet SQLResult=SQLStatement.executeQuery(Query);

    //get and display each record
    while(SQLResult.next())
    {
    String name=SQLResult.getString("name");
    out.println("<option>" +name);

    Question:How can I access the name selected by the user such that I will be able to insert add'l info to it?

    I have the following code but it registered "null" values in the journal and publisher columns of the Volume table.

    in addVolume.jsp:

    String name=request.getParameter("name");
    String publisher=request.getParameter("publisher");
    String vol_no=request.getParameter("vol_no");
    String acc_no=request.getParameter("acc_no");

    String Query="INSERT INTO volume VALUES('"+name+"','"+publisher+"','"+vol_no+"','"+acc_no+"')";

    note:
    the Journal table has 2 columns for name & publisher while
    the Volume table would inherit the contents of the journal table and has add'l column for volume and accession number.
    Last edited by chloe4irene; March 22nd, 2003 at 05:09 AM.
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    I am not clear what your problem is. You say
    I have the following code but it registered "null" values in the journal and publisher columns of the Volume table.
    But you only have html shown that returns the "name" field. I assume "name" is ok? Also, I see no reference anywhere to a "journal" field, neither in your html nor your query.

    We need more accurate information. Post more code and more details please.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    12
    Rep Power
    0

    re:codes


    I had posted my codes at CLIENT SIDE forum on HTML, JAVASCRIPT & CSS.

    kindly verify them. Pls bear with my poor codings. Im really new to this stuff.
  6. #4
  7. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    Breifly looking at your jsp, it appears you may be having a problem because the 'select' for the journals is not in a form, and thus cannot be submitted. When and if you do submit the page with one of the other forms, that field will not be transfered with the rest of the data.
    Code:
    <html>
    
    <head>
    <title>Insert Journal</title>
    <SCRIPT>
    <!--
    function F_loadRollover(){} function F_roll(){}
    //-->
    
    function select()
    {
    
    
    }
    </SCRIPT>
    <SCRIPT LANGUAGE="JavaScript1.2" SRC="./rollover.jsp"></SCRIPT>
    
    </head>
    <body bgcolor=orange>
    <BODY NOF="(MB=(ZeroMargins, 0, 6, 0, 0), L=(SearchLayout, 1025, 750))" 
    BGCOLOR="#FFFFFF" BACKGROUND="background.gif" TEXT="#000000" LINK="#0033CC" 
    VLINK="#990099" ALINK="#FF0000" TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
     <CENTER>
     <FORM NAME="LAYOUTFORM" ACTION="results.jsp" METHOD=POST>
      <TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0 WIDTH=1024 NOF=LY height="1">
       <TR VALIGN=TOP ALIGN=LEFT>
        <TD width="93" height="1"></TD>
         <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=1 NOF=LY height="60">
          <TR VALIGN=TOP ALIGN=LEFT>
           <TD HEIGHT=60 COLSPAN=2 ALIGN=CENTER VALIGN=MIDDLE WIDTH=136></TD>
          </TR> 
         </TABLE>
        
        <TD WIDTH=54 height="61"></TD>
        <TD width="244" height="61"><b><font size="10" color="black">
      INSERT</font></b></TD>
        <TD WIDTH=161 height="61"></TD>
        <TD WIDTH=1 height="61"></TD>
        <TD width="900" height="115">
          <TR VALIGN=TOP ALIGN=LEFT>
        <TD HEIGHT=29 width="93"></TD>
        <TD WIDTH=900 height="29"></TD>
         <br>
         <TABLE ID="navMain" BORDER=0 CELLSPACING=1 CELLPADDING=0 NOF=NB_UYHPNY120 WIDTH=364 height="44">
          <TR VALIGN=TOP ALIGN=LEFT>
           <TD WIDTH=120 height="50">
    		 <A HREF="./Journal.jsp" onMouseOver="F_roll('NavigationButton1',1)" onMouseOut="F_roll('NavigationButton1',0)">
    		 <IMG ID="NavigationButton1" NAME="NavigationButton1" HEIGHT=30 WIDTH=120 
    		 SRC="./Autogen/Journal_Hp3.gif" onLoad="F_loadRollover(this,'Journal_HRp4.gif',0)" BORDER=0 ALT="JOURNAL"></A>
    		 </TD>
           <TD WIDTH=120 height="50">
    		 <A HREF="./Volume.jsp" onMouseOver="F_roll('NavigationButton2',1)" onMouseOut="F_roll('NavigationButton2',0)">
    		 <IMG ID="NavigationButton2" NAME="NavigationButton2" HEIGHT=30 WIDTH=120 Volume.blur() 
    		 SRC="./Autogen/Volume_Np1.gif" onLoad="F_loadRollover(this,'Volume_NRp2.gif',0)" BORDER=0 ALT="VOLUME"></A>
    		 </TD>
           <TD WIDTH=120 HEIGHT="50">
    		 <A HREF="./Issue.jsp" onMouseOver="F_roll('NavigationButton3',1)" onMouseOut="F_roll('NavigationButton3',0)">
    		 <IMG ID="NavigationButton3" NAME="NavigationButton3" HEIGHT=30 WIDTH=120 
    		 SRC="./Autogen/Issue_Np1.gif" onLoad="F_loadRollover(this,'Issue_NRp2.gif',0)" BORDER=0 ALT="ISSUE"></A>
    		 </TD>
           <TD WIDTH=120 height="50">
    		 <A HREF="./Article.jsp" onMouseOver="F_roll('NavigationButton4',1)" onMouseOut="F_roll('NavigationButton4',0)">
    		 <IMG ID="NavigationButton4" NAME="NavigationButton4" HEIGHT=30 WIDTH=120 
    		 SRC="./Autogen/Article_Npl.gif" onLoad="F_loadRollover(this, 'Article_NRp2.gif', 0)" BORDER=0 ALT="ARTICLE"></A>
    		 </TD>
          </TR>
         </TABLE>
        <TD width="31" height="29"></TD>
       </TR>
      </TABLE>
     </FORM>
    </BODY>
    </CENTER>
    
    <p align="center">
    <br>
    <b>
    <font color="black" face="Arial"><U>Select Journal:</U></font></b></b></b></p>
    
    <p align="center">
    <br>
    
    <!--SELECT is only used for the dropdown list of the journals already inserted-->
    
    <select name="name" size="1" id="name" onChange="select()">
    <option><%=course%></option>
    <%@ include file ="showJournal.jsp"%>
    </select></p>
    
    <!--must declare a function na magrereturn ng name of the selected journal -->
    
     
    <CENTER>
    <form method="POST" action="addVolume.jsp">
     <TR VALIGN=TOP ALIGN=LEFT>
      <TD COLSPAN=2></TD>
      <TD WIDTH=117>
      <br><br>
      <p>
      <font face="Arial" color="#000000"><b>Volume Number:</b></font><font color="gray"> </font> 
      <input name="vol_no" type="text" size="17">
      <br><br>
      <font face="Arial" color="#000000"><b>Accession Number:</b></font><font color="gray">
       </font> <input name="name" type="text" size="20">
      </p>
      <br><br>
      <p>
      <input type="submit" value="Submit" >
      <br><br>
      </p>
      </td>
     </tr>
    </form>
    </CENTER>
    </body>
    
    </html>
    It's the first place I would start.
    Last edited by Nemi; March 23rd, 2003 at 02:35 PM.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    12
    Rep Power
    0
    I have tried including the 'select' in a form I used for that certain page but I still couldn't access the selected option of the user from the dropdown menu.

    Is there anything that I need to include in my page?
  10. #6
  11. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    I really need to see your new code. Can you post it?

IMN logo majestic logo threadwatch logo seochat tools logo