How can we pass selected combo box value to a jsp pag?
Hi All,
I want to pass selected combo box value to a same jsp page's variable.
i am using javascript
<select onchange="this.options[this.selectedIndex].text">
</select>
this selected value should be invoked for a jsp page's variable.
Excepting for favorable reply
Vansh
select2.jsp
<script>
function x()
alert(document.f.s.options[document.f.s.selectedIndex].text);
document.f.submit();
</script>
<body>
<form method="get" name="f" action="select2.jsp">
<select name="s" onchange="x()">
<option checked>--select--</option>
<option value="1"> vijay </option>
<option value="2"> kumar </option>
</select>
</form>
</body>
Similar Messages
-
How can I make the combo box turn to the value of black.
When the show button is pressed (and not before), a filled black square should be
displayed in the display area. The combo box (or drop down list) that enables the user to choose the colour of
the displayed shape and the altering should take effect immediately.When the show button is pressed,
the image should immediately revert to the black square, the combo box should show the value that
correspond to the black.
Now ,the problem is: after I pressed show button, the image is reverted to the black square,but I don't know
how can I make the combo box turn to the value of black.
Any help or hint?Thanks a lot!
coding 1.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class test extends JFrame {
private JPanel buttonPanel;
private DrawPanel myPanel;
private JButton showButton;
private JComboBox colorComboBox;
private boolean isShow;
private int shape;
private boolean isFill=true;
private String colorNames[] = {"black", "blue", "cyan", "darkGray", "gray",
"green", "lightgray", "magenta", "orange",
"pink", "red", "white", "yellow"}; // color names list in ComboBox
private Color colors[] = {Color.black, Color.blue, Color.cyan, Color.darkGray,
Color.gray, Color.green, Color.lightGray, Color.magenta,
Color.orange, Color.pink, Color.red, Color.white, Color.yellow};
public test() {
super("Draw Shapes");
// creat custom drawing panel
myPanel = new DrawPanel(); // instantiate a DrawPanel object
myPanel.setBackground(Color.white);
// set up showButton
// register an event handler for showButton's ActionEvent
showButton = new JButton ("show");
showButton.addActionListener(
// anonymous inner class to handle showButton events
new ActionListener() {
// draw a black filled square shape after clicking showButton
public void actionPerformed (ActionEvent event) {
// call DrawPanel method setShowStatus and pass an parameter
// to decide if show the shape
myPanel.setShowStatus(true);
isShow = myPanel.getShowStatus();
shape = DrawPanel.SQUARE;
// call DrawPanel method setShape to indicate shape to draw
myPanel.setShape(shape);
// call DrawPanel method setFill to indicate to draw a filled shape
myPanel.setFill(true);
// call DrawPanel method draw
myPanel.draw();
myPanel.setFill(true);
myPanel.setForeground(Color.black);
}// end anonymous inner class
);// end call to addActionListener
// set up colorComboBox
// register event handlers for colorComboBox's ItemEvent
colorComboBox = new JComboBox(colorNames);
colorComboBox.setMaximumRowCount(5);
colorComboBox.addItemListener(
// anonymous inner class to handle colorComboBox events
new ItemListener() {
// select shape's color
public void itemStateChanged(ItemEvent event) {
if(event.getStateChange() == ItemEvent.SELECTED)
// call DrawPanel method setForeground
// and pass an element value of colors array
myPanel.setForeground(colors[colorComboBox.getSelectedIndex()]);
myPanel.draw();
}// end anonymous inner class
); // end call to addItemListener
// set up panel containing buttons
buttonPanel = new JPanel();
buttonPanel.setLayout(new GridLayout(4, 1, 0, 50));
buttonPanel.add(showButton);
buttonPanel.add(colorComboBox);
JPanel radioButtonPanel = new JPanel();
radioButtonPanel.setLayout(new GridLayout(2, 1, 0, 20));
Container container = getContentPane();
container.setLayout(new BorderLayout(10,10));
container.add(myPanel, BorderLayout.CENTER);
container.add(buttonPanel, BorderLayout.EAST);
setSize(500, 400);
setVisible(true);
public static void main(String args[]) {
test application = new test();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
coding 2
import java.awt.*;
import javax.swing.*;
public class DrawPanel extends JPanel {
public final static int CIRCLE = 1, SQUARE = 2;
private int shape;
private boolean fill;
private boolean showStatus;
private int shapeSize = 100;
private Color foreground;
// draw a specified shape
public void paintComponent (Graphics g){
super.paintComponent(g);
// find center
int x=(getSize().width-shapeSize)/2;
int y=(getSize().height-shapeSize)/2;
if (shape == CIRCLE) {
if (fill == true){
g.setColor(foreground);
g.fillOval(x, y, shapeSize, shapeSize);
else{
g.setColor(foreground);
g.drawOval(x, y, shapeSize, shapeSize);
else if (shape == SQUARE){
if (fill == true){
g.setColor(foreground);
g.fillRect(x, y, shapeSize, shapeSize);
else{
g.setColor(foreground);
g.drawRect(x, y, shapeSize, shapeSize);
// set showStatus value
public void setShowStatus (boolean s) {
showStatus = s;
// return showstatus value
public boolean getShowStatus () {
return showStatus;
// set fill value
public void setFill(boolean isFill) {
fill = isFill;
// set shape value
public void setShape(int shapeToDraw) {
shape = shapeToDraw;
// set shapeSize value
public void setShapeSize(int newShapeSize) {
shapeSize = newShapeSize;
// set foreground value
public void setForeground(Color newColor) {
foreground = newColor;
// repaint DrawPanel
public void draw (){
if(showStatus == true)
repaint();Hello,
does setSelectedIndex(int anIndex)
do what you need?
See Java Doc for JComboBox. -
How can we pass the master report value in to detail report
Hi All,
My question is how can I pass the master report value in to detail (Child) report filter?
I mean I have one master report if I click on employee name then I have to pass the employee id in to details report filter. Then detail report will display data for that particular employee.
How can I achieve this one in OBIEE?
Please help me to resolve this issue. Thanks in advance for your time and support.In that case, you should look at using Go Url. In your column formula for the employee name, create a hyperlink to the detail report and pass the employee id.
Take a look at this post: Re: Dyanmic display of the Image Link URL
Thanks! -
Hi,
I want a code in jsp or javascript for selecting combo box value and it is assigned to another variable.
Example: If combo box value is Number, it is assigned to 0. If como box value is Name, it is assigned to 1.hey thanks for the info hunter...but it is related to core java..actually im workin on jsp,html n stuff..so any help on tht would be refreshing..
vinay -
How can I make a gray box or gray screen in Pages over a few lines of text?
How can I make a gray box or gray screen in Pages over a few lines of text?
Thanks. Almost what I was looking for.
While that makes for a gray over the lines, it still does not form a box.
Any other suggestions to form a solid rectangular gray box? -
How can we use java variable in javascript code on JSP page?
How can we use java variable in javascript code on JSP page?
Pls helpThink about it:
JSP/Java is executed on the Server and produces HTML+JavaScript.
Then that HTML+JavaScript is transfered to the client. The client now interpretes the HTML+JavaScript.
Obviously there's no way to access a Java variable directly from JavaScript.
What you can do, however, is write out some JavaScript that creates a JavaScript variable containing the value of your Java variable. -
How can I access xml document from javascript whithin a JSP page
how can I access xml document from javascript whithin a JSP page?
I have a JSP that receives an XML document from a JavaBean, so I can access it within the entire JSP, but I need to access it from the javascript inside the JSP... and I have no idea how i can do this.
Thanks in advance!The solution would only work on MS IE browsers, as other browsers do not support an XML DOM.
It can be done, but you would be stuck with using the Microsoft broswer. If that is acceptable, I have some example code, and a book recommendation. -
How can i pass a variable's value from PR to PFR
Dear all,
hope you are fine.
i would like to pass a variable's value from PR to PFR.
how can i do that.
please suggest.
in PR:
String transactionId = (String) vo_trans.first().getAttribute("Getnexttrans");
i would like to get this value to PFR.Mofizur,
You can achieve the same using Session variable.
If u are not executing the VO after PR. Then you will be able to get the same value as u are using in PR
String transactionId = (String) vo_trans.first().getAttribute("Getnexttrans");
Note - You have a few of the threads left open, mark it as answered if solved.
Regards,
Gyan -
I have 2 combo boxes If I have data table like below
TableA
ID NAME
1 A
2 B
3 C
4 A
I make "TableA" as data source of "combobbox1" and "combobox2" like
combobox1.datasource = TableA
combobox1.displaymember = "ID"
combobox2.datasource = TableA
combobox2.displaymember = "Name"
I want when combobox2 select index at "A" , Combobox1 show only the items at ID = 1 And ID = 4
ThanksThis is not actually a question to be posted in SQL Server. Here is a link for ASP.NET forum.
http://forums.asp.net/
It looks like there is a filter that can be applied in .NET dataset and populate the results in your combobox1. You may get better help from .NET forums for this question. -
How can I make the combo box extend fully (so there is no scroll bar) like in IE?
When I select a combo box in IE the box opens "all the way" and there is no vertical scroll bar. This way I can see all of the options and now have to scroll up and down.
Is there a way to set Firefox to do the same?I have repeated the test with nightly, but this time created the new profile on a local filesystem (ext4 FWIW) rather than an NFS-mounted one. As before the timestamp on .parentlock is not updated when firefox exits, so almost certainly a bug. If there is a problem with permissions/ownership, that problem is created by firefox, so still a bug :-) (given that the profile is a brand new one).
I'll report this on bugzilla as soon as I can. -
How can I pass a variable to an applet in JSP?
I want to invoke an Applet in JSP and pass a variable( ie. port) to the Applet. I do as follows:
<applet code="best.Applet1.class" width=400 height=300 >
<param name=port1 value=port>
</applet>
in Applet1.java , I use getParameter("port1"),yet I got character string "port" ,not the value of port(i.e. 100).
How can I get 100 not "port"? Thanks!!!Assuming that port is a variable defined and initailized in the jsp:
<applet code="best.Applet1.class" width=400 height=300 >
<param name=port1 value=<%= port %>>
</applet> -
How can I pass an object to a function by value?
Hi
I have a function with an argument. this argument is an object. I don't want to alter this object. But java passes this object by reference and some fields in this object are altered after function return.
How can I pass this object by value and keep my original data unbroken?
thanks for any helpa.toraby wrote:
I have a function with an argument. this argument is an object. I don't want to alter this object. But java passes this object by reference and some fields in this object are altered after function return.
How can I pass this object by value and keep my original data unbroken?How you approach it is likely to depend on how much control you have over the code in question. If it's legacy code and has been badly designed, there's probably very little you can do to protect existing code short of a complete refactoring.
What you could do as an interim measure is:
1. Create an immutable wrapper to your existing mutable class.
2. Create new methods that replicate the existing ones, but take the immutable class instead.
3. Deprecate the old methods.
This won't break client code, but they will now get warnings when they compile and you can add documentation to point them to the new class/methods.
If you are in control of the code (especially if you're still in the design stages), you've got several options:
1. As Dr.Clap says, make your class immutable (probably best).
2. If this isn't possible, create mutable and immutable variants of your class. This is often best achieved by hanging them both from an interface.
Winston -
Passing values to the JSP page - Urgent
Hi all,
I have to pass the user id value to the JSP page. I have written the following code in the doInitialization() method
IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
IPortalComponentContext myContext = request.getComponentContext();
IPortalComponentProfile myProfile = myContext.getProfile();
IAuthentication ia = UMFactory.getAuthenticator();
IUser portalUser = ia.getLoggedInUser(request.getServletRequest(), request.getServletResponse(false) );
s = portalUser.getUniqueName();
IPortalComponentSession componentSession = ((IPortalComponentRequest)getRequest()).getComponentSession();
Object o = componentSession.getValue("myEvents");
myEvents = (LoadEvents)o;
//myEvents = (LoadEvents) myContext.getValue("myEvents");
myEvents.setUserId(s);
myContext.putValue("myBeanName", myEvents);
I have also defined myEvents as a bean in my JSP page with scope APPLICATION. But I get User Id as "NULL".
Thanks in advance.
Rgds,
Janvi.Hi Prakash,
Please find the jsp code pasted below:
<hbj:content
id="myContext">
<hbj:page
title="Successful processing">
<jsp:useBean id="myMeet" scope="application" class="com.sap.ep.bluestar.LoadEvents" />
<jsp:useBean id="myEvents" class="com.sap.ep.bluestar.MonthView" scope="application" />
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" %>
<%
int leadSpaces, daysInMonth, leadSpaces_next,daysInMonth_next, col_Counter;
myCal.setMonthView();
java.util.Vector printVal_pre = new java.util.Vector();
myCal.printMonth(myCal.getPre_month(),myCal.getPre_year());
printVal_pre = myCal.getPrintValues();
java.util.Vector printVal_cur = new java.util.Vector();
myCal.printMonth(myCal.getCur_month(),myCal.getCur_year());
printVal_cur = myCal.getPrintValues();
java.util.Vector printVal_next = new java.util.Vector();
myCal.printMonth(myCal.getNext_month(),myCal.getNext_year());
printVal_next = myCal.getPrintValues();
if(request.getMethod().equals("POST")){
try {
String action =(String) request.getParameter("action");
if(action.equals("insert")){
// response.sendRedirect("_insertEvent.jsp");
//response.sendRedirect("test.html");
} catch(Exception e) {
System.out.println(e.getMessage());
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script language="javascript">
function insertEvent(frm,eventDay){
alert("here finally " + eventDay + " " + frm.eventMonth.value + " " + frm.eventYear.value );
frm.action.value = "insert";
frm.submit();
function openWin(frm,eventDay)
var newWin = window.open("http://localhost:50100/irj/servlet/prt/portal/prtroot/Web_Calendar.eventHandler?variable=" + frm.eventMonth.value + "/" + eventDay + "/" + frm.eventYear.value, 'popup',
'resizable,height=200,width=325');
if(newWin.focus) newWin.focus();
</script>
</head>
<body>
User is : <%= myCal.getUserId() %>
<table width="745" height="583" border="0">
<tr>
<td width="258" height="23" align="center"><B> <% out.println(printVal_pre.elementAt(0).toString() + " " + printVal_pre.elementAt(1).toString());
leadSpaces = ((Integer)printVal_pre.elementAt(2)).intValue();
daysInMonth = ((Integer)printVal_pre.elementAt(3)).intValue();
%> </B> </td>
<td width="215"> </td>
<td width="258" align="center"><B> <% out.println(printVal_next.elementAt(0).toString() + " " + printVal_next.elementAt(1).toString());
leadSpaces_next = ((Integer)printVal_next.elementAt(2)).intValue();
daysInMonth_next = ((Integer)printVal_next.elementAt(3)).intValue();
%> </B></td>
</tr>
<tr>
<td height="151"><table width="245" border="1">
<tr>
<th width="35" scope="col"><div align="center">S</div></th>
<th width="35" scope="col"><div align="center">M</div></th>
<th width="35" scope="col"><div align="center">T</div></th>
<th width="35" scope="col"><div align="center">W</div></th>
<th width="35" scope="col"><div align="center">T</div></th>
<th width="35" scope="col"><div align="center">F</div></th>
<th width="35" scope="col"><div align="center">S</div></th>
</tr><tr>
<% col_Counter = 0;
for (int i = 0; i < leadSpaces; i++) {
out.print("<td> </td>");
col_Counter++;
for (int i = 1; i <= daysInMonth; i++) {
// This "if" statement is simpler than messing with NumberFormat
if(i < 9) {
out.print("<td align='center'>" + " " + i + "</td>");
col_Counter++;
} else {
out.print("<td align='center'>" + i + "</td>");
col_Counter++;
if ((leadSpaces + i) % 7 == 0) { // Wrap if EOL
out.println("</tr><tr>");
int cnt = col_Counter;
if(col_Counter == 28){
out.println("</tr>");
}else {
for(int i = 0; i < (42 - col_Counter);i++){
out.print("<td> </td>");
cnt++;
if((cnt%7) ==0)
out.println("</tr><tr>");
out.println("</tr>");
%>
</table></td>
<td> </td>
<td><table width="245" border="1">
<tr>
<th width="35" scope="col"><div align="center">S</div></th>
<th width="35" scope="col"><div align="center">M</div></th>
<th width="35" scope="col"><div align="center">T</div></th>
<th width="35" scope="col"><div align="center">W</div></th>
<th width="35" scope="col"><div align="center">T</div></th>
<th width="35" scope="col"><div align="center">F</div></th>
<th width="35" scope="col"><div align="center">S</div></th>
</tr>
<tr>
<% col_Counter = 0;
for (int i = 0; i < leadSpaces_next; i++) {
out.print("<td> </td>");
col_Counter++;
for (int i = 1; i <= daysInMonth_next; i++) {
// This "if" statement is simpler than messing with NumberFormat
if(i < 9) {
out.print("<td align='center'>" + " " + i + "</td>");
col_Counter++;
} else {
out.print("<td align='center'>" + i + "</td>");
col_Counter++;
if ((leadSpaces_next + i) % 7 == 0) { // Wrap if EOL
out.println("</tr><tr>");
cnt = col_Counter;
if(col_Counter == 28){
out.println("</tr>");
}else {
for(int i = 0; i < (42 - col_Counter);i++){
out.print("<td> </td>");
cnt++;
if((cnt % 7 ) ==0)
out.println("</tr><tr>");
out.println("</tr>");
%>
</table></td>
</tr>
<tr>
<td colspan="3"><table width="735" height="383" border="1">
<tr>
<td colspan="7" align="center"><B> <% out.println(printVal_cur.elementAt(0).toString() + " " + printVal_cur.elementAt(1).toString());
leadSpaces = ((Integer)printVal_cur.elementAt(2)).intValue();
daysInMonth = ((Integer)printVal_cur.elementAt(3)).intValue();
%> </B></td>
</tr>
<tr>
<th width="105" scope="col">SUN</th>
<th width="105" scope="col">MON</th>
<th width="105" scope="col">TUE</th>
<th width="105" scope="col">WED</th>
<th width="105" scope="col">THUR</th>
<th width="105" scope="col">FRI</th>
<th width="105" scope="col">SAT</th>
</tr>
<form name="eventCal" method="post" action="Web_Cal.jsp">
<input name="eventMonth" type="hidden" value="<%= myCal.getCur_month() + 1 %>">
<input name="eventYear" type="hidden" value="<%=myCal.getCur_year() %>">
<input name="action" type="hidden" value="">
<tr>
<% col_Counter = 0;
for (int i = 0; i < leadSpaces; i++) {
out.print("<td> </td>");
col_Counter++;
for (int i = 1; i <= daysInMonth; i++) {
// This "if" statement is simpler than messing with NumberFormat
if(i < 9) {
out.print("<td align='center'>" + " " + "<a href='javascript:openWin(document.eventCal," + i + ");'>" + i + "</a></td>");
col_Counter++;
} else {
out.print("<td align='center'>" + "<a href='javascript:openWin(document.eventCal," + i + ");'>" + i + "</a></td>");
col_Counter++;
if ((leadSpaces + i) % 7 == 0) { // Wrap if EOL
out.println("</tr><tr>");
if(col_Counter == 28){
out.println("</tr>");
}else if(col_Counter < 35){
for(int i = 0; i < (35 - col_Counter);i++)
out.print("<td> </td>");
out.println("</tr>");
}else {
for(int i = 0; i < (42 - col_Counter);i++)
out.print("<td> </td>");
out.println("</tr>");
%> </form>
</table></td>
</tr>
</table>
</body>
</html>
</hbj:textView>
</hbj:page>
</hbj:content>
Regards,
Janvi -
How can we pass the select-option value to modulepool program?
hi,
how can we pass the select-option value to modulepool program ?
Because if i declared select-options in executable program and i used SSCRFIELDS to define push buttons in selection screen.
My requirement if enter the values to select-options and press UPDATE pussbotton then i want call screen which contains tablecontrol.
How i get select-option values to PAI of call screen for getting the data from database table to my internal table?Oh I thought that you have selection-screen and again you are working on dialog programming.
if you want to use select-option directly in module pool then it is not possible.
but you can do other way.
create two varaiables
data : v_kun_low like kna1-kunnr,
v_kun_high like kna1-kunnr.
use these two variables in layout ,let user knows that he can not give options like gt,lt,eq ,it will be always BT.
and also when you see normal report program,you can use multiple values in either low or high,but here it is not possibel.
use can enter only low value and high value.
when you come to program point of view
declare one range
ranges r_kunnr for kna1-kunnr.
do the coding like
r_kunnr-low = v_kun_low.
r_kunnr-high = v_kun_high.
r_kunnr-options = 'BT'.
r_kunnr-sign = 'I'.
append r_kunnr.
now you can use r_kunnr in select query ,it will work like select-option.
other than this there is no option.
Thanks
Seshu -
How to pass a combo box parameter on reporting services?
How to pass a combo box parameter on reporting services?
For example, a report has a parameter which is a combo box, its items came from a database query.
Looks like the combo box didn't got populated and greyed out if I didn't pass the parameter.Hi LAScorpion,
In Reporting Services, if we want to pass a combo box parameter (means signal-parameter) from one report (main report) to another report (subreport), we can enable an action with “Go to report” or “Go to URL” option to achieve the requirement. For more details,
please see:
Method1: Go to report
Right-click a report item to open the properties dialog in subreport, click Action in the left pane.
Enable Go to report action, then select the main report name in the drop-down list.
Add a parameter as below:
Select ID (a parameter name from main report) in the drop-down list of Name, and select [ID] (a field name from subreport) in the drop-down list of Value.
Method2: Go to URL
Right-click a report item to open the properties dialog in subreport, click Action in the left pane.
Enable Go to URL action, the URL below is for your reference:
="javascript:void(window.open('http://server_name/ReportServer/Pages/ReportViewer.aspx?%2ffolder_name%2fmain_report_name&rs:Command=Render¶meter_name="& Parameters!parameter_name.Value &"'))"
Besides, if the parameter’s values are based on other parameters, then the combo-box got greyed out when we haven’t select values in preceding parameters. For more details, please see:
Cascading Parameters
If there are any misunderstanding, please elaborate the issue for further investigation.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support
Maybe you are looking for
-
Final cut is not reading events or projects from my external hard drive, what can I do?
Final Cut X is not reading events of projects from my external hard drive, what can i do?
-
How do I save as PDF/A, PDF/A-1b in Acrobat XI Strandard?
How do I save as PDF/A, PDF/A-1b compliant in Acrobat XI Strandard? I want to archive some of my PDF files. I want them to meet generally used archived standards. My install of ACrobat Standard was a standard install. Is this something I can only
-
(java.sql.SQLException) Invalid column type
On Jdeveloper 11.1.2 on Windows7 64b I got this table : create table entry (entry_id number(32) not null, entry_class_id varchar2(5) not null, notes varchar2(200) not null, active varchar2(1) default 'Y' not null, interface varchar2(1) default 'N' no
-
In order to Remove Knowledge Management Navigation iViews Commands from menus 1) I identified layoutset used in the KM iview 2) In System Admin>System Config>KM >Content management>User interface--> I copied the layoutset and modified the copied lay
-
What is the latest version of InDesign on CC?
I just ran the Adobe updater and downloaded the latest version (8.0.???). Someone sent me a file and it won't open because it says that it is a newer version? 9.1? I thought that was why we had the CC, to have access to the latest versions of everyth