473,397 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

capturing value of drop-down box

52
hi,
i am getting the values for the drop-down box from the database. On selection of an option and on the click of a button it does unique actions for each option.
But, i am unable to capture the value of the option, since i am retrieving from database it displays the options in same order always..
please help....
Apr 24 '07 #1
6 2376
r035198x
13,262 8TB
hi,
i am getting the values for the drop-down box from the database. On selection of an option and on the click of a button it does unique actions for each option.
But, i am unable to capture the value of the option, since i am retrieving from database it displays the options in same order always..
please help....
Where are you not able to capture the value of the option. Can you explain the problem a bit more?
Apr 24 '07 #2
mallz
52
Where are you not able to capture the value of the option. Can you explain the problem a bit more?
in the second form on which i retrieve the values from the database again for display in the combo box, but this time, i want what i have selected in form1 to be displayed in the combobox
Apr 24 '07 #3
r035198x
13,262 8TB
in the second form on which i retrieve the values from the database again for display in the combo box, but this time, i want what i have selected in form1 to be displayed in the combobox
Post the codes you have used for the combo and for retrieving the value.
Apr 24 '07 #4
mallz
52
Post the codes you have used for the combo and for retrieving the value.
Form1:

Filter by Status: <select name="stat" >
Expand|Select|Wrap|Line Numbers
  1.  <%! 
  2.         Connection con=null;
  3.         Statement st=null;
  4.         ResultSet rs=null;    
  5. %>
  6.  
[HTML] <%
String statusname=null;
try
{
con=DbUtil.getConnection();
st=con.createStatement();

try
{
String query="select * from status";
rs=st.executeQuery(query);
}
catch(Exception e)
{
System.out.println(e);
}
while(rs.next())
{
statusname=rs.getString("statusname");
//System.out.println(statusname);
%>
<option value=<%=statusname%>><%=statusname%></option>
<%
}
con.commit();
}
catch(Exception e1)
{
System.out.println(e1);
}
finally
{
rs.close();
st.close();
}
%>

</select>
<input type=submit value="Go!" onFocus = "statvalidation(this.form)">
[/HTML]
in form1 i am retrieving these values from database, the options being a,b,c,d

Form2:

in form 2 i have the same code repeated, but if he selects 'c' in form1, and clicks button go, the dropdown box in form2 should have 'c' as its selected option, but by default it is showing as 'a', as i am retrieving from database....
Apr 24 '07 #5
r035198x
13,262 8TB
Form1:

Filter by Status: <select name="stat" >
<%!
Connection con=null;
Statement st=null;
ResultSet rs=null;
%>


<%
String statusname=null;
try
{
con=DbUtil.getConnection();
st=con.createStatement();

try
{
String query="select * from status";
rs=st.executeQuery(query);
}
catch(Exception e)
{
System.out.println(e);
}
while(rs.next())
{
statusname=rs.getString("statusname");
//System.out.println(statusname);
%>
<option value=<%=statusname%>><%=statusname%></option>
<%
}
con.commit();
}
catch(Exception e1)
{
System.out.println(e1);
}
finally
{
rs.close();
st.close();
}
%>

</select>
<input type=submit value="Go!" onFocus = "statvalidation(this.form)">

in form1 i am retrieving these values from database, the options being a,b,c,d

Form2:

in form 2 i have the same code repeated, but if he selects 'c' in form1, and clicks button go, the dropdown box in form2 should have 'c' as its selected option, but by default it is showing as 'a', as i am retrieving from database....
Please always use code tags when posting code.

Where is form1 submitting to? If it is submitting to form 2 then pass then retrieve the selected value in form2 and then use an if else for displaying the options

Expand|Select|Wrap|Line Numbers
  1.  if(valueFromDatabase.equals(valueFromForm1)) { 
  2. %>
  3. <OPTION value="<%=valueFromDatabase%>" selected > <%=valueFromDatabase%></OPTION>
  4. <%
  5. else {
  6. %>
  7. <OPTION value="<%=valueFromDatabase%>" > <%=valueFromDatabase%></OPTION>
  8. <%
  9. }
  10. %>
  11.  
Apr 24 '07 #6
mallz
52
Please always use code tags when posting code.

Where is form1 submitting to? If it is submitting to form 2 then pass then retrieve the selected value in form2 and then use an if else for displaying the options

Expand|Select|Wrap|Line Numbers
  1.  if(valueFromDatabase.equals(valueFromForm1)) { 
  2. %>
  3. <OPTION value="<%=valueFromDatabase%>" selected > <%=valueFromDatabase%></OPTION>
  4. <%
  5. else {
  6. %>
  7. <OPTION value="<%=valueFromDatabase%>" > <%=valueFromDatabase%></OPTION>
  8. <%
  9. }
  10. %>
  11.  
Thanks a lot, the piece of code you posted solved the problem
Apr 25 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Michael Winter | last post by:
I'll be frank: what is the point? The use, and usefulness, of a set of capturing parentheses in a regular expression is clear. However, isn't an expression such as "/(?:x)/", exactly the same as...
33
by: Joerg Schuster | last post by:
Hello, Python regular expressions must not have more than 100 capturing groups. The source code responsible for this reads as follows: # XXX: <fl> get rid of this limitation! if...
5
by: Bruce | last post by:
I have several user defined functions which are referenced in triggers and views. For software upgrades, I need to be able to drop the triggers and views which reference these user defined...
10
by: Andrew | last post by:
Hi, I have a messagebox that pops up due to an event. I did it in javascript. ie. alert("Time's up. Assessment Ended"); I want to capture the OK and Cancel events of this alert messagebox. My...
2
by: coolnoff | last post by:
I have a dts which creates a table which is utilized on my local intranet. The DTS runs without error and the table is created/populated/transfered to the appropriate db. Then it appears that...
3
by: rajibnsu | last post by:
While searching for capturing video with a webcam I god the following code.It gives two errors.Says:The type or namespace name 'WebcamEventArgs' does not exit in the namespace 'WebCam_Capture' (are...
2
by: =?Utf-8?B?UHVjY2E=?= | last post by:
I'm getting the following Errors during run time and I tried capturing it using the code below but I'm not able to. I'm also showing in Debug the value is {}. How can I catch this so it won't...
0
by: supriya51902003 | last post by:
Hi All, Can any one help me regarding this problem-- I have a windows form with a webbrowser control. I want to drag a file from my PC and drop on Webbrowser control. The Webbrowser will...
6
by: kapro | last post by:
PHP behaves strange when capturing 'return' value, how to over come? when i echo the value inside the function, it works fine. if i return a value from the function, it return nothing... why? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.