Update Combo box choice
I have written the below code. When "Equipment1_combo" is selected, the respective choice will be update into the "Equipment1_pcs". E.g. if I chose "Racket", it show the quantity from 0 to 12 (assume that the equipment_inventory dB have 12 as quantity of racket).
<%
Connection dbcon2;
Statement statement2;
Statement statement3;
ResultSet rs2;
ResultSet rs3;
//connect to DB
try
String driver2 = "com.mysql.jdbc.Driver";
String dbURL2 = "jdbc:mysql://localhost/fyp";
Class.forName(driver2).newInstance();
dbcon2 = DriverManager.getConnection(dbURL2);
System.out.println("Connection to database is successful");
catch(ClassNotFoundException e)
System.out.println("Database driver could not be found.");
System.out.println(e.toString());
throw new UnavailableException(this, "Database driver class not found");
catch(SQLException e)
System.out.println("Error connecting to the database.");
System.out.println(e.toString());
throw new UnavailableException("Cannot connect to the database");
statement2 = dbcon2.createStatement();
rs2 = statement2.executeQuery("SELECT DISTINCT CATEGORY from EQUIPMENT_INVENTORY ORDER BY CATEGORY ASC");
statement3 = dbcon2.createStatement();
rs3 = statement3.executeQuery("SELECT QUANTITY from EQUIPMENT_INVENTORY where CATEGORY='"+request.getParameter("Equipment1_combo")+"' ");%>
<p><b>Reserve Equipment </b></p>
<p><b><i>Equipment 1</i></b>
<select name="Equipment1_combo">
<% while (rs2.next()) {%>
<option value = "<%=rs2.getString("Category")%>"><%=rs2.getString("Category")%></option>
<%}%>
</select> No. of pieces
<select name="Equipment1_pcs">
<% while (rs3.next()) {%>
<option value = "<%=rs3.getString("Quantity")%>"><%=rs3.getString("Quantity")%></option>
<%}
rs3.close();
%>
</select></p>
Right then.
JSP is a server side language. All the code gets run at the server, and returned to the client as an HTML page. The only method of communication you have to the server is by submitting an html form.
Therefore jsp code can not react to events on the form such as selecting an item from the list directly.
There are 2 options
1 - javascript - handles client side interaction with a web page - use javascript/vbscript to change the values in the combo.
2 - when they select an item in the list, resubmit the form with that parameter, and generate the jsp accordingly (ie reload the page)
This is not an uncommon question. Do a quick forum search and you come up with plenty of related posts
Check out these links
http://onesearch.sun.com/search/developers/index.jsp?col=devforums&qp=&qt=combo+jsp+javascript+select+dynamic
http://forum.java.sun.com/thread.jsp?forum=54&thread=203309
http://forum.java.sun.com/thread.jsp?forum=45&thread=145694
Similar Messages
-
While updating combo box in a JTable, after updating the first row when pointer (logical) goes to the second row it says value already exists. Kindly let me know if anyone has the solution for the same.
While updating combo box in a JTable, after updating the first row when pointer (logical) goes to the second row it says value already exists. Kindly let me know if anyone has the solution for the same.
-
Programmatically update Combo box won't update its Local variable
Hello all,
I followed a tutorial from NI website and programmatically edit items in a combo box. It worked successfully but not for the Local variables. Local variables still retain items that it had before.
Any suggestions ?
Thanks !
Solved!
Go to Solution.You need to programmatically update the value property in order to change what the local variable will return, the value that you will wire doesn't have to match with one of the Strings[] array.
Perhaps you need to do something like this to update your value to change from "Two" to "Five". -
Combo Box choices hide or show buttons
I am trying to have different pictures display when different choices are made in a combo box. I have made the pictures images on different buttons. The Combo Box name is "Ribbon" . Under one of the button images is this script.
var target =
this.getField('Ribbon');
cBox.value = ('RIBREG').Display=display.hidden; cBox.value = ('RIBFOIL').Display=display.visible;
meaning if RIBFOIL was chosen this button would display
Of course it is not working. Any input would be greatly appreciated.
Thanks!Good Morning,
cbox.value is the Combo Box seletion. I finally did get this to work . The below code is posted under the combo box instead of the actual image.
Thanks for your reply!
if(event.value == 'RIBREG'){
this.getField('Image Rib 1').hidden = true; //
this.getField('Image Rib 2').hidden = false; //
if(event.value == 'RIBFOIL'){
this.getField('Image Rib 1').hidden = false; // -
I have 3 fields.
Field 1 is a combo box that provides the choice BZ7 or BZS.
Field 2 is a text box (Monthly Gross) that calculates another boxes "Base Salary" * 26 pay periods for BZ7. I want it to be set up so that If i choose BZS that calculation will change to 24 pay periods and for BZ7 the 26.You can set these numbers as the Export Values for each of the options in the combo-box, and then simply use the built in Product calculation option to multiply the value of the combo-box with the "Base Salary" text field.
-
Trying to update table based on combo box choice
Hey all,
I have taken over code someone has created and it is confusing me what they have done. the code uses an abstracttablemodel to create the table (and i assume, fill the data). I can't for the life of me, figure out how the data is loaded. Can someone tell me what is happening. also, what would be the easiest way to update it to only show that info that matches the criteria? I will post what i think is relevant code, but if i am missing something, i will be happy to throw it in there. Here's the code:
public class ABMD extends JPanel implements ActionListener
private JTable table;
private TableSorter sorter;
public ABMD()
sorter = new TableSorter(new ABMDTableModel());
table = new JTable(sorter);
sorter.setTableHeader(table.getTableHeader());
ListSelectionModel rowSM = table.getSelectionModel();
rowSM.addListSelectionListener(new ListSelectionListener()
public void valueChanged(ListSelectionEvent e)
if (e.getValueIsAdjusting()) return;
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty())
viewDataButton.setEnabled(false);
getDataButton.setEnabled(false);
removeDataButton.setEnabled(false);
else
int selectedRow = sorter.modelIndex(table.getSelectedRow());
PlanData currentPlanData = (PlanData) planArrayList.get(selectedRow);
if (!currentPlanData.getPlanListLoaded())
getDataButton.setEnabled(true);
viewDataButton.setEnabled(false);
removeDataButton.setEnabled(false);
else
getDataButton.setEnabled(false);
viewDataButton.setEnabled(true);
removeDataButton.setEnabled(true);
String desc = "";
desc = currentPlanData.getUniqueID();
descTextAreaValue.setText(desc);
class ABMDTableModel extends AbstractTableModel
private String[] columnNames = {"Plan Local",
"OPLAN",
"Air Defense Plan",
"Planning Period",
"Defense Design",
"Published Date"
public int getColumnCount()
return columnNames.length;
public int getRowCount()
return planArrayList.size();
public String getColumnName(int col)
return columnNames[col];
public Object getValueAt(int row, int col)
PlanData planData = (PlanData) planArrayList.get(row);
switch(col)
case 0:
return Boolean.valueOf(planData.getPlanListLoaded());
case 1:
return planData.getOplan();
case 2:
return planData.getAirDefensePlan();
case 3:
return planData.getPlanningPeriod();
case 4:
return planData.getDefenseDesign();
case 5:
return planData.getPublishedDate();
throw new IllegalArgumentException("Illegal Column: " + getColumnName(col));
public Class getColumnClass(int c)
return getValueAt(0, c).getClass();
public boolean isCellEditable(int row, int col)
return false;
}I can't for the life of me, figure out how the data is loadedLooking at the get value method we see:
PlanData planData = (PlanData) planArrayList.get(row);Therefore the data is store in the "planArrayList". So the data is loaded whenever you add data to that ArrayList. -
For example:
Combo box choices:
apple
tomato
squash
Pumpkin
The text box depending on the selection above would state the color:
Green (if Apple was chosen from the combo box
Red (if Tomato was chosen from the combo box
Yellow (if Squash was chosen from the combo box
Orange (if Pumpkin was chosen from the combo box
I am very new at this and have spent hours looking for an answer. Thank to anyone in advance who can help!Place each value as the export value of the options in the combo-box and then use this code as the text field's custom calculation script:
event.value = this.getField("ComboBox Name").value; -
Pleasel let me know if there is a way to copy and paste choices for a Combo Box from an Excel spreadsheet or text file. I have over 250 values I'd like to add and don't trust my typing!
Thanks for the help!
Ken K. - 2191Yes, using the field.getItemAt method: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.745.html
E.g.:
var aItems = [];
var f = getField("combo1");
for (var i = 0; i < f.numItems; i++) {
aItems[i] = f.getItemAt(i);
If there are export values you need to decide how to use the optional bExportValue parameter. -
Hi All,
I'm developing a Form which has BP Code and a ComboBox which, after entering a valid Supplier in the BPCode EditText, updates the ComboBox with the Supplier Catalog Numbers of all the Items where the CardCode (in OITM) matches the BPCode. I have this working for the first change of BPCode but when the BPCode changes I want to update the ComboBox ValidValues. I have tried many methods but cannot remove the ValidValues which are already there. I have tried linking the ComboBox to a DataTable, clearing the DataTable and rebinding but this doesn't seem to work either.
Any help on removing ValidValues from a list when I don't know what is already there (as the VV list is now out of scope) or adding a data bound ComboBox would be most appreciated.
Thanks in anticipation,
DavidHi David,
Try following
'get the reference to the state combo box
oCombo = oForm.Items.Item("combo box unique id").Specific
'remove existing items if any
'before adding new items
For Flag = 0 To oCombo.ValidValues.Count - 1
oCombo.ValidValues.Remove(0, SAPbouiCOM.BoSearchKey.psk_Index)
Next
After this, use a recordset or datatable to retrieve the records, and than a loop to add valid values to the combo box.
Rahul -
Combo box list update or insert restriction
Dear all,
I have a list item which type is combo box.
it shows the Departments list from the department table at run time.
i populate at through a procedure at runtime.
problem
the user could update the list by writing something into it.
i want to force the user to just select a value from the list, not update or insert.
i change the properties of the list item which prevent insertion or updation,
but it disable the selection from the list as well.
how to prevent the user to write something in the combo box list while giving him the
selection authority using the combo box list item?
Thanks and Regardsthank you dear,
but i want to use the combo box instead.
for popup list there is a problem of the null value,
you must assign a value to the popup list and set its required property to true for doing so.
and the combo box do not need this. and my desired functionality require it.
Edited by: Muhammad on Feb 28, 2010 3:10 AM
Edited by: Muhammad on Feb 28, 2010 3:21 AM -
How to update items in combo box programmat​ically
I have a problem on updating items in combo box programmatically, such as add or remove a item from the list. I can add or delete without any problem once the vi is running. I can see it is changed by pressing drop button. But after I close the vi and rerun it, the change I did last time is lost. It seems it not permenatly change the list. Anyone has an idea?
If you are changing the list programmatically why do you believe that it should be permanent? If it's permanent, why are you changing it programmatically? Doesn't make a whole lot of sense.
If you're talking about saving the values as "default" in the same way you do with the development environment, you cannot do this with an EXE. This is a FAQ. You have to update the list programmatically, saving the "new" default values to file. -
Strange behaviour with my updating of combo box
public class EditVideoDialog extends JPanel implements ActionListener{
JTextField text_Name, text_Price, text_Producer, path_Picture;
JTextArea textarea_Description;
public JComboBox combo_Genre, combo_Name;
String old_VideoName;
Vector <String> myVideoName = new Vector <String>();
public EditVideoDialog(){
public EditVideoDialog(Vector <String> myVideoName){
combo_Name = new JComboBox();
combo_Name.setEditable(false);
combo_Name.setMaximumRowCount(4);
combo_Name.setPreferredSize(new Dimension(300,25));
currentVideoName(myVideoName);
//Function to set current video name
public void currentVideoName(Vector <String>videoName){
combo_Name.removeAllItems();
combo_Name.addItem("");
for(int k =0; k<videoName.size(); k++){
combo_Name.addItem(videoName.get(k));
}I tried with the script above, the combo_box first got compiled nicely after retrieving data from the database.
However, when i tried to do the updating of combo box with function currentVideoName, it fails.
I also tried puttng a ComboBoxModel inside my function but it fails. It just doesn't get updated...
ComboBoxModel model = new DefaultComboBoxModel(myVideoName);
combo_Name.setModel(model);can someone advise me or show me some simple code on this?
Edited by: diskhub on Mar 16, 2008 11:27 AMhttp://forum.java.sun.com/thread.jspa?threadID=5275345
-
How do you get the value of a combo box as the operator scrolls thru the list with the arrow keys? Combo box updates once the operator presses enter but I would like the value in real-time.
Thanks,
Paul
I have attached a very small example I am working with. I need it to work with the event structure in order for it to be implemented into my current software.
Attachments:
Combo Box Update.vi 36 KBHi Novatronics,
You could try replacing it with a Dialog Ring?
See attached.
Charlie Rodway
Test Design Engineer
Rolls-Royce Controls and Data Services Ltd
Attachments:
Dialog Ring Update.vi 47 KB -
Tonight opening Numbers caused a 'free update available box' advising me to install the latest version of OS X and then download the latest version of numbers. 'OK' is the only choice.
I can't force quit Numbers or even shutdown the iMac.
I don't want to lose the spreadsheet (90% completed so far) or upgrade to Yosemite.
I have OS X 10.9.5 running on a 2014 iMac.
What to do?
Thanks.NOTE: Just discovered that Adobe is making a bigger mess than any previously.
They now have a 32-bit uninstaller for Flash '''''AND''''' a separate 64-bit uninstaller for Flash. You will need the 64-bit uninstaller for what you had installed above.
*32-bit uninstaller: http://download.macromedia.com/pub/flashplayer/current/uninstall_flash_player_32bit.exe
*64-bit uninstaller: download.macromedia.com/pub/flashplayer/current/uninstall_flash_player_64bit.exe -
SBO 2005 combo box does not update value at first time
Hi!I developed an addon for sbo 2004 with a combo box populated with the months of the year, and it works. The same code run on SBO 2005 works only after the second selection. Has anyone found the same problem?
definition of the item:
item = form.Items.Add("oMese", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX)
item.Left = 245
item.Top = 5
item.Width = 80
item.DisplayDesc = True
combo = item.Specific
combo.DataBind.SetBound(True, "", "uMese")
combo.ValidValues.Add(1, "Gennaio")
combo.ValidValues.Add(2, "Febbraio")
event handling:
inside ItemEvent in case the item is selected
Case SAPbouiCOM.BoEventTypes.et_COMBO_SELECT
Select Case pVal.FormUID
Case "PRG_UFM_0002_RegIVAAcq"
retCode = oTy_RACQ.FormComboSelect(pVal, BubbleEvent)
Public Shared Function FormComboSelect(ByVal pVal As SAPbouiCOM.ItemEvent, _
ByRef BubbleEvent As Boolean, _
ByRef funCaller As Object, _
ByVal funCallerID As Integer, _
ByRef aForm As SAPbouiCOM.Form) _
As Integer
Dim msg As String
Dim edt As SAPbouiCOM.EditText
Dim cmb As SAPbouiCOM.ComboBox
Dim obt As SAPbouiCOM.OptionBtn
Dim cbx As SAPbouiCOM.CheckBox
Dim mtx As SAPbouiCOM.Matrix
Try
If pVal.Before_Action = True Then
Select Case pVal.ItemUID
Case "oMese"
Dim stre As New strEstremi
cmb = aForm.Items.Item("oMese").Specific
edt = aForm.Items.Item("anno").Specific
If Not cmb.Selected Is Nothing Then
GetEstremiPeriod(edt.Value, cmb.Selected.Value, "M", stre)
edt = aForm.Items.Item("dtFrom").Specific
edt.String = stre.dtFrom
edt = aForm.Items.Item("dtTo").Specific
edt.String = stre.dtTo
End If
end function
thank you I hope is enough otherwise please tell me
Maybe you are looking for
-
HT201104 how can I move my iCloud folder to another drive on my pc
How can I move my iCloud folder from one drive (C:\) on my PC to another drive (E:\) on the same PC? I have more space available on E:\ than I have on C:\ so I want to take advantage of the extra space, but not sure how or if I can move my iCloud f
-
A mysterious audio file opens when I open my browser. How do I find and delete it?
A mysterious audio file opens when I open my browser. How do I find and delete it?
-
IPhoto has disappeared!!! How do i get it back??
HELP!! My iphoto is/was located on an external harddrive. it was workong fine. the only 2 new things i did was register my computer to DropBox & re-plugged in my external harddrive via a newUSB 3.0 Hub, to give me extra USB ports. My externaldrive th
-
Will ipod touch4 mains charger work with ipod touch5
I purchased an iPod touch 5 for my little one , I have an iPod touch 4 , can I use the mains wall charger to charge the touch5 with the new lead , or is the only way to charge it through the USB on my laptop
-
Itunes keeps crashing on my windows 7 64-bit computer every time I log in to iTunes match. I have tried uninstalling and reinstalling. How do I clear my registry files or something else?