jsp and servlet

1 view
Skip to first unread message

bankim pandya

unread,
Mar 31, 2010, 8:50:10 AM3/31/10
to open-traini...@googlegroups.com
<div align="center">CUSTOMER ID</div>
  </label></td>
  <td width="277"> <form id="form3" name="form3" method="post" action="">
   
   
  <div align="center">
  <select name="Customer">
  <% 
  Class.forName("oracle.jdbc.driver.OracleDriver");
  Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:PKEL", "SYS AS SYSDBA", "bankim");
  Statement st=con.createStatement();
  ResultSet result=st.executeQuery(" select * from CUSTOMER_MASTER ");
  while(result.next()){
  String name=result.getString(1);
  %>
  <option value="<%=name%>">
  <%out.println(name);%>
  </option>
  <%}con.close(); %>  
  </select>
  </div>
  </form></td></tr>
Sir i want the value of that is selected by user using the list box without submitting the form i.e on same jsp what should i do................

Kinnaree Patel

unread,
Mar 31, 2010, 9:31:06 AM3/31/10
to open-traini...@googlegroups.com
You can get it using javascript. Give id in select input box and the get the value of select box using document.getElementById('ID Given').value

PS.: Hope this is not the live code. You need to make a lot of modifications if this is a real time code.

--
You received this message because you are subscribed to the Google
Groups "open-training-community" group.
To post to this group, send email to
open-traini...@googlegroups.com
To unsubscribe from this group, send email to
open-training-com...@googlegroups.com
For more options, visit this group at
http://groups.google.co.in/group/open-training-community?hl=en-GB

bankim pandya

unread,
Mar 31, 2010, 11:45:15 AM3/31/10
to open-traini...@googlegroups.com
thanx for ur help but it is not workin means i have to fire a query wid "where" clause using this value jsp solution would be a better help for me

Ashish Rana

unread,
Apr 1, 2010, 3:18:37 AM4/1/10
to open-traini...@googlegroups.com


try to implement ajax .

there are libraries available .


bankim pandya

unread,
Apr 1, 2010, 11:57:47 PM4/1/10
to open-traini...@googlegroups.com
it is done thanx

Ritesh Suthar

unread,
Apr 2, 2010, 11:59:38 AM4/2/10
to open-traini...@googlegroups.com
Bankin,

Please do not close thread just by replying "it's done thanx" - you also need to share you solution approach so the community.

Regards,
Ritesh 

On Fri, Apr 2, 2010 at 9:27 AM, bankim pandya <bankim.p...@gmail.com> wrote:
it is done thanx


--
You received this message because you are subscribed to the Google
Groups "open-training-community" group.
To post to this group, send email to
open-traini...@googlegroups.com
To unsubscribe from this group, send email to
open-training-com...@googlegroups.com
For more options, visit this group at
http://groups.google.co.in/group/open-training-community?hl=en-GB



--
Regards,
Ritesh
Cell: +919925151637

bankim pandya

unread,
Apr 2, 2010, 10:55:26 PM4/2/10
to open-traini...@googlegroups.com
i am really sorry for that the solution that i used is as under

this is javascript i used:

<script language="javascript">
var intTextBox=0;
function getCustomerName()
{

document.form3.action="";
document.form3.submit();
}
</script>

and jsp code is as follows


   <select name="Customer" onchange="getCustomerName();">
                          <option></option>

                            <%
                            Class.forName("oracle.jdbc.driver.OracleDriver");
                            Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:PKEL", "SYS AS SYSDBA", "bankim");
                            Statement st=con.createStatement();
                            ResultSet result=st.executeQuery(" select * from CUSTOMER_MASTER ");
                            while(result.next()){
                            name=result.getString(1);
                            %>
                            <option value="<%=name%>">
                            <%out.println(name);%>
                            </option>
                            <%}con.close(); %>       
                   
                          </select>
                               
                      </div>
                               <%
                               cust_id=request.getParameter("Customer");
                               Class.forName("oracle.jdbc.driver.OracleDriver");
                               Connection con11=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:PKEL", "SYS AS SYSDBA", "bankim");
                               Statement st11=con11.createStatement();
                               ResultSet result11=st11.executeQuery(" select * from CUSTOMER_MASTER where CUST_ID='" + cust_id + "' ");
                               while(result11.next()){
                                name11=result11.getString(3);
                                name12=result11.getString(1);
                               %>
                             
              </form>
              <%} con11.close();%></td></tr>
            <tr>
              <td height="42"><label>
              <div align="center">CUSTOMER_ID/NAME</div>
              </label></td>
           
              <td>
               
                  
                      <div align="center">
                                <label>  <%if(name12==null)
                                         {   
                                                   
                                         }
                                         else
                                         {         
                                         out.println(name12);
                                        }%></label>
                             <label>  <%if(name11==null)
                                         {   
                                                   
                                         }
                                         else
                                         {         
                                         out.println(name11);
                                        }
                                      %></label>   

Shardul Bhatt

unread,
Apr 3, 2010, 9:20:14 AM4/3/10
to open-traini...@googlegroups.com
Thanks Bankim.

Regards,
Shardul.
Reply all
Reply to author
Forward
0 new messages