Testing for no selection of combo box - mandatory combo
What si the best way to see if a combo box has not been selected when it does not have a default value?
if (ocombo.Selected.Value="")
Hi,
some solutions
in c#
if (((SAPbouiCOM.ComboBox)(oForm.Items.Item("cmbUID").Specific)).Selected != null) {
in vb6
if (NOT(oForm.Items.Item("cmbUID").Specific.Selected is nothing)) then
you can also try
if( oCombobox.Selected is null)
lg David
Similar Messages
-
Combo Box Selection to Change Selection in another Combo Box
I'm pretty familiar with excel and VBA, but when it comes to Adobe Acrobat, I am lost with Javascript.
I am creating a form.
My first field is a combo box named: Rent.booth
My second field is also a combo box named: County.booth
I need to know where and how I would implement a java command that states that if Rent.booth = Rent, then County.booth automatically = No.
If No is selected for Rent.booth, then allow the user to choose any of the 3 values.
Combo Box Options for Rent.booth:
Select One
Rent
No
Combo Box Options for County.booth:
Select One
Yes
No
Any leads would be appreciated. So far I've only seen the Combo Box to Text box solutions, nothing for Combo box to Combo Box.You'll get the best help with Javascript in the Acrobat Scripting forum.
-
How to test for différent Select into a single PL/SQL block ?
Hi,
I am relatively new to PL/SQL and I am trying to do multiple selects int a single PL/SQL block. I am confronted to the fact that if a single select returns no data, I have to go to the WHEN DATA_NOT_FOUND exception.
Or, I would like to test for different selects.
In an authentification script, I am searching in a table for a USER ID (USERID) and an application ID, to check if a user is registered under this USERID for this APPLICATION.
There are different possibilities : 4 possibilities :
- USERID Existing or not Existing and
- Aplication ID found or not found for this particular USERID.
I would like to test for thes 4 possibilities to get the status of this partiular user regardin this application.
The problem is that if one select returns no row, I go to the exception data not found.
In the example below you see that if no row returned, go to the exception
DECLARE
P_USERID VARCHAR2(400) DEFAULT NULL;
P_APPLICATION_ID NUMBER DEFAULT NULL;
P_REGISTERED VARCHAR2(400) DEFAULT NULL;
BEGIN
SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES
WHERE USERID = :P39_USERID AND APPLICATION_ID = :APP_ID ;
:P39_TYPE_UTILISATEUR := 'USER_REGISTERED';
EXCEPTION
WHEN NO_DATA_FOUND THEN
:P39_TYPE_UTILISATEUR := 'USER_NOT_FOUND';
END;I would like to do first this statement :
SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES
WHERE USERID = :P39_USERID Then to do this one if the user is found :
SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES
WHERE USERID = :P39_USERID AND APPLICATION_ID = :APP_ID ;etc...
I basically don't want to go to the not found exception before having tested the 4 possibilities.
Do you have a suggestion ?
Thank you for your kind help !
ChristianSurely there are only 3 conditions to check?
1. The user exists and has that app
2. The user exists and doesn't have that app
3. The user doesn't exist
You could do this in one sql statement like:
with mimic_data_table as (select 1 userid, 1 appid from dual union all
select 1 userid, 2 appid from dual union all
select 2 userid, 1 appid from dual),
-- end of mimicking your table
params_table as (select :p_userid userid, :p_appid appid from dual)
select pt.userid,
pt.appid,
decode(min(case when dt.userid = pt.userid and dt.appid = pt.appid then 1
when dt.userid = pt.userid then 2
else 3
end), 1, 'User and app exist',
2, 'User exists but not for this app',
3, 'User doesn''t exist') user_app_check
from mimic_data_table dt,
params_table pt
where pt.userid = dt.userid (+)
group by pt.userid, pt.appid;
:p_userid = 1
:p_appid = 2
USERID APPID USER_APP_CHECK
1 2 User and app exist
:p_userid = 1
:p_appid = 3
USERID APPID USER_APP_CHECK
1 3 User exists but not for this app
:p_userid = 3
:p_appid = 2
USERID APPID USER_APP_CHECK
3 2 User doesn't exist -
How to view the records in datagrid using Combo Box Selection
hi friends,
i having one combo box,that combo box having 10 students name in list format.
If i click any one of the students name it will only show the Particular student record in datagrid with respective fields(student name,rollnumber,percentage);
how i will do this
please give any suggession or show snippet demo.
it will be more helpful to do this,
Thanks in advance
B.Venktesan.Hi,
As your requirement , i think you will have to use selectedItem or selectedIndex property of combobox. And accordingly fetch data and provide it to dataprovider of datagrid.Following code can help you.
<?xml version="1.0" encoding="utf-8"?>
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="
library://ns.adobe.com/flex/spark" xmlns:mx="
library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import spark.components.List;[
Bindable]
var array:ArrayCollection = new ArrayCollection();
public function insert():void{
array.addItem(Combo1.selectedItem
as String);DG1.dataProvider=array;
]]>
</fx:Script>
<s:ComboBox x="118" y="64" id="Combo1" change="insert()" >
<s:dataProvider>
<s:ArrayList>
<fx:String>AAA</fx:String>
<fx:String>BBB</fx:String>
<fx:String>CCC</fx:String>
</s:ArrayList>
</s:dataProvider>
</s:ComboBox>
<mx:DataGrid x="118" y="154" id="DG1" >
<mx:columns>
<mx:DataGridColumn>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid></s:Application>
Thanks and Regards,
Vibhuti Gosavi | [email protected] | www.infocepts.com -
Hi there,
I have been searching for the answer for this question.
I am trying to write JavaScript for the following situation. If my check box is selected then the values of combo box 1, combo box 2, and combo box 3, will all read "N/A". My fields in each combo box is " " "yes" "no" and "N/A" If someone could help me out with this answer that would be greatly appreciated.
Thank you.Hi
You need to use following Javascript code in Acrobat form to achieve your requirement.
if((this.getField("CheckBox1").isBoxChecked(0)))
this.getField("Dropdown1").value = "N/A";
this.getField("Dropdown2").value = "N/A";
this.getField("Dropdown3").value = "N/A";
if((!this.getField("CheckBox1").isBoxChecked(0)))
this.getField("Dropdown1").value = " ";
this.getField("Dropdown2").value = " ";
this.getField("Dropdown3").value = " ";
Please see attached PDF for reference.
Regards,
Anoop -
Combo Box Edits in acrobat Forms, how to do a multi-line combo box?
Could only create a one-liners for this editable combo box, is there a way to create a multi-line like the other fields?
Nope. But you can set up a multiline text field that gets populated with the complete text you want when an item is selected from a combo box.The combo box items might be abbreviated or coded versions of the complete text you want to display.
-
How do I remove empty space combo box
My promblem is that I have empty space between selected option and the other option Below are code i used to build this combo box .This combo box display list of possible user of the system and selected option show to the currrent user of the system. Code are
<% sql_query = "SELECT em_num, em_name, dfu_usr_id "+
" FROM dfusrf, emmast "+
" WHERE dfu_emp_id = em_num "+
" ORDER BY em_name ";
try{
rset = db.execSQL(sql_query);
while ( rset.next()){
String em_num2 = rset.getString("em_num");
String em_nme2 = rset.getString("em_name");
%>
<option value="<%= em_num2 %>">
<% if ( em_num2.equals(em_num) ){%>
<option value="<%= em_num2 %>"selected>
<%= em_nme2 %></option>
<%} // end if
%><%= em_nme2 %></option>
<%} // end while
} // end try
catch ( Exception e )
System.err.println("Error in query - emmast2 - transaction_main.jsp " +e.getMessage() + " sql " + sql_query);
finally
if ( rset != null ) rset.close();
%>
</select>while ( rset.next())
String SELECTED = "";
String em_num2 = rset.getString("em_num");
String em_nme2 = rset.getString("em_name");
if ( em_num2.equals(em_nme2) )
SELECTED = " SELECTED ";
%>
<option <%=SELECTED%> value="<%= em_num2 %>"><%= em_nme2 %></option>
<%
} // end while -
Push Button , Label and combo box
Hi Experts,
Currently facing a problem , please guide.
I have two push buttons say A and B and one combo box.
I am using Combo box with source data as filtered row options.
What I want to accomplish is when push button A is clicked then my combo box should have different souce of data say sheet 1 in excel and when Push button B is clicked then the same combo box should have source data from sheet 2 from the same excel.
I mean dynamic selection of source data and then destination data by using combo boxed.
is it possible ?
Thanks in advance.
Thanks & Regards,
AnjnaHi,
Use 2 combo boxs CB1 n CB 2.
CB1 : source form sheet1
CB2:Source from sheet 2
when push button A is selected set dynamic visibility such that u get combo box 1
when push button B is selected set dynamic visibility such that u get combo box 2.
Case 2:
Insted of using 2 push buttons you can use a radio butoon and select the lables A or B so that these two combo box components dnt appear at once
Take a radio button component and map lables as A and B
under behaviour tab: >Insert selected item:>mapp it with a blank cell say Sheet3!$G$4
if radio button selection is A then set dynamic visibility such that u get combo box 1
if radio button selection is b then set dynamic visibility such that u get combo box 2
formula cells:
take a blak cell say Sheet3!$H$7 and write formula =IF(Sheet3!$G$4="A","",first label of combo box 2)
take a blak cell say Sheet3!$H$8 and write formula =IF(Sheet3!$G$4="B","",first label of combo box 1)
Combo box 1 :Behaviour tab-->Selected item :Sheet3!$H$7
Combo box 1 :Behaviour tab-->Selected item :Sheet3!$H$8
check if this suits ur req ...
@Sri
Edited by: Sri kamesh on Jun 21, 2011 11:00 AM -
Powershell Unique Selections for Multiple Combo Boxes
I am currently working on a powershell script that will use 4 combo box controls. I would like for them to all use the same data source whether it be an array or just a .txt file. I would like for each selection to be unique so that no 2 combo boxes can
have the same item selected. Is there a way to hide the item selected in the data source so the other combo boxes do not even have the option to select it and then when the user changes the item in one of the combo boxes the item is available again?What I am looking do do is have a list of values (T1111,T1112,T1113,T1114) to be selected from by 4 combo boxes. Each value can only be selected once so if one combo box picks T1111 the other 3 do not have that option in its selection. So far I reload the
combo boxes ever time a selection is made and remove the option from the array, but I was looking to see if there is a better way. As it currently stands, getting distinct values isn't working.
Code snippet to remove item from array:
function Get-DataSource
$array = @("T1111", "T1112", "T1113", "T1114")
$combo1 = $combobox1.SelectedItem.ToString()
$combo2 = $combobox2.SelectedItem.ToString()
$array = $array | Where-Object -FilterScript { $_ -ne $combo1 }
$array = $array | Where-Object -FilterScript { $_ -ne $combo2 }
return $array
I apologize for not uploading my code.
function OnApplicationLoad {
#Note: This function is not called in Projects
#Note: This function runs before the form is created
#Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path
#Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList)
#Important: Form controls cannot be accessed in this function
#TODO: Add modules and custom code to validate the application load
return $true #return true for success or false for failure
function OnApplicationExit {
#Note: This function is not called in Projects
#Note: This function runs after the form is closed
#TODO: Add custom code to clean up and unload modules when the application exits
$script:ExitCode = 0 #Set the exit code for the Packager
#endregion Application Functions;2
# Generated Form Function
function Call-tenet_psf {
#region Import the Assemblies
[void][reflection.assembly]::Load('mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
[void][reflection.assembly]::Load('System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
[void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
[void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
[void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
[void][reflection.assembly]::Load('System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
[void][reflection.assembly]::Load('System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
[void][reflection.assembly]::Load('System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
[void][reflection.assembly]::Load('System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
#endregion Import Assemblies
#region Generated Form Objects
[System.Windows.Forms.Application]::EnableVisualStyles()
$form1 = New-Object 'System.Windows.Forms.Form'
$combobox2 = New-Object 'System.Windows.Forms.ComboBox'
$combobox1 = New-Object 'System.Windows.Forms.ComboBox'
$buttonOK = New-Object 'System.Windows.Forms.Button'
$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
#endregion Generated Form Objects
# User Generated Script
function OnApplicationLoad {
#Note: This function is not called in Projects
#Note: This function runs before the form is created
#Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path
#Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList)
#Important: Form controls cannot be accessed in this function
#TODO: Add modules and custom code to validate the application load
return $true #return true for success or false for failure
function OnApplicationExit {
#Note: This function is not called in Projects
#Note: This function runs after the form is closed
#TODO: Add custom code to clean up and unload modules when the application exits
$script:ExitCode = 0 #Set the exit code for the Packager
$FormEvent_Load={
#TODO: Initialize Form Controls here
Load-ComboBox $combobox1 (Get-DataSource)
Load-ComboBox $combobox2 (Get-DataSource)
function Get-DataSource
$array = @("T1111", "T1112", "T1113", "T1114")
$combo1 = $combobox1.SelectedItem.ToString()
$combo2 = $combobox2.SelectedItem.ToString()
$array = $array | Where-Object -FilterScript { $_ -ne $combo1 }
$array = $array | Where-Object -FilterScript { $_ -ne $combo2 }
return $array
#region Control Helper Functions
function Load-ComboBox
<#
.SYNOPSIS
This functions helps you load items into a ComboBox.
.DESCRIPTION
Use this function to dynamically load items into the ComboBox control.
.PARAMETER ComboBox
The ComboBox control you want to add items to.
.PARAMETER Items
The object or objects you wish to load into the ComboBox's Items collection.
.PARAMETER DisplayMember
Indicates the property to display for the items in this control.
.PARAMETER Append
Adds the item(s) to the ComboBox without clearing the Items collection.
.EXAMPLE
Load-ComboBox $combobox1 "Red", "White", "Blue"
.EXAMPLE
Load-ComboBox $combobox1 "Red" -Append
Load-ComboBox $combobox1 "White" -Append
Load-ComboBox $combobox1 "Blue" -Append
.EXAMPLE
Load-ComboBox $combobox1 (Get-Process) "ProcessName"
#>
Param (
[ValidateNotNull()]
[Parameter(Mandatory=$true)]
[System.Windows.Forms.ComboBox]$ComboBox,
[ValidateNotNull()]
[Parameter(Mandatory=$true)]
$Items,
[Parameter(Mandatory=$false)]
[string]$DisplayMember,
[switch]$Append
if(-not $Append)
$ComboBox.Items.Clear()
if($Items -is [Object[]])
$ComboBox.Items.AddRange($Items)
elseif ($Items -is [Array])
$ComboBox.BeginUpdate()
foreach($obj in $Items)
$ComboBox.Items.Add($obj)
$ComboBox.EndUpdate()
else
$ComboBox.Items.Add($Items)
$ComboBox.DisplayMember = $DisplayMember
$combobox1_SelectedIndexChanged={
#TODO: Place custom script here
Load-ComboBox $combobox2 -Items (Get-DataSource)
$combobox2_SelectedIndexChanged={
#TODO: Place custom script here
Load-ComboBox $combobox1 -Items (Get-DataSource)
# --End User Generated Script--
#region Generated Events
$Form_StateCorrection_Load=
#Correct the initial state of the form to prevent the .Net maximized form issue
$form1.WindowState = $InitialFormWindowState
$Form_Cleanup_FormClosed=
#Remove all event handlers from the controls
try
$combobox2.remove_SelectedIndexChanged($combobox2_SelectedIndexChanged)
$combobox1.remove_SelectedIndexChanged($combobox1_SelectedIndexChanged)
$form1.remove_Load($FormEvent_Load)
$form1.remove_Load($Form_StateCorrection_Load)
$form1.remove_FormClosed($Form_Cleanup_FormClosed)
catch [Exception]
#endregion Generated Events
#region Generated Form Code
$form1.SuspendLayout()
# form1
$form1.Controls.Add($combobox2)
$form1.Controls.Add($combobox1)
$form1.Controls.Add($buttonOK)
$form1.AcceptButton = $buttonOK
$form1.ClientSize = '614, 289'
$form1.FormBorderStyle = 'FixedDialog'
$form1.MaximizeBox = $False
$form1.MinimizeBox = $False
$form1.Name = "form1"
$form1.StartPosition = 'CenterScreen'
$form1.Text = "Form"
$form1.add_Load($FormEvent_Load)
# combobox2
$combobox2.FormattingEnabled = $True
$combobox2.Location = '123, 92'
$combobox2.Name = "combobox2"
$combobox2.Size = '121, 21'
$combobox2.TabIndex = 2
$combobox2.add_SelectedIndexChanged($combobox2_SelectedIndexChanged)
# combobox1
$combobox1.FormattingEnabled = $True
$combobox1.Location = '123, 64'
$combobox1.Name = "combobox1"
$combobox1.Size = '121, 21'
$combobox1.TabIndex = 1
$combobox1.add_SelectedIndexChanged($combobox1_SelectedIndexChanged)
# buttonOK
$buttonOK.Anchor = 'Bottom, Right'
$buttonOK.DialogResult = 'OK'
$buttonOK.Location = '140, 254'
$buttonOK.Name = "buttonOK"
$buttonOK.Size = '75, 23'
$buttonOK.TabIndex = 0
$buttonOK.Text = "&OK"
$buttonOK.UseVisualStyleBackColor = $True
$form1.ResumeLayout()
#endregion Generated Form Code
#Save the initial state of the form
$InitialFormWindowState = $form1.WindowState
#Init the OnLoad event to correct the initial state of the form
$form1.add_Load($Form_StateCorrection_Load)
#Clean up the control events
$form1.add_FormClosed($Form_Cleanup_FormClosed)
#Show the Form
return $form1.ShowDialog()
} #End Function
#Call OnApplicationLoad to initialize
if((OnApplicationLoad) -eq $true)
#Call the form
Call-tenet_psf | Out-Null
#Perform cleanup
OnApplicationExit -
Plotting a combination chart with a combo box for selection
Hi:
I am a newbie using xcelcius and I need help on the following:-
I need to create a combination chart that plots 3 years data by month, and I need a combo box selection at the top that allows me to select user display for each difference region. I manage to create one that plots only 2008 data with a combo-box selection, but I have no idea how to do it for a combi chart in xcelcius. Any advise?Hi Ning,
I assume your data are like this:
Region Year Jan Feb Mar
APJ 2006 $234.45 $310.34 $321.54
APJ 2007 $314.35 $319.12 $256.89
APJ 2008 $425.54 $354.34 $285.73
North Asia 2006 $534.64 $642.35 $484.64
North Asia 2007 $631.74 $654.13 $754.34
North Asia 2008 $754.31 $423.65 $634.32
South East Asia 2006 $536.42 $576.35 $525.42
South East Asia 2007 $426.78 $876.43 $643.75
South East Asia 2008 $634.87 $425.77 $732.43
If this, you can set the insertion type of combo box is "Filtered Rows", see steps:
1) For Combo Box, bind General > Labels to the Region column.
2) Set General > Data Insertion > Insertion Type is "Filtered Rows" (you can refer to following flash to see how "Filtered Rows" works).
3) Set its Source Data are Year, Jan, Feb, ... columns and Destination to blank cells.
4) Bind Chart to the destination data.
Now when you select APJ from Combo Box, it will insert all the rows of APJ data to the desitination cells which will be displayed in Chart.
Hope this can help! -
Distinct dataset for selection combo box
Hi,
I have a dataset displayed on my page with paging and
dependant detail region as well as filter functions. Works like a
charm. For a visual look
here
My issue is this: To enable the filter with drop down select
list (aka combo box) shown in the picture I implemented the
following code
var transactlist_xml = new
Spry.Data.XMLDataSet("transactlist-xml.php",
"export/row",{sortOnLoad:"account",sortOrderOnLoad:"ascending",useCache:false,loadInterva l:60000});
var accounts_xml = new
Spry.Data.XMLDataSet("transactlist-xml.php",
"export/row/account",{sortOnLoad:"account",sortOrderOnLoad:"ascending",distinctOnLoad:tru e});
The first dataset selects the data for the entire list, the
second for the combo box. It works alright, but I deam it to be
very inefficient. I have to call the php script that does the data
selection twice, which means double the database load. Not good.
Since I have selected all the data I need in the first statement,
is away I can reduce the number of direct source reads and costruct
the second dataset out of the first?
I tried
var accounts_xml = transactlist_xml.distinct();
with no success, as transactist_xml has all the fields still
included, so clearly the rows will not be distinct.
Any suggestions/thougts?
Any hint is appreciated.
Hanno Schupp"How to Use The Focus Subsystem"
http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html -
Deleting some of the entries in the Combo-box for the selection field
Hi All,
We are running on SRM 4.0(Classic).I have a query reagarding the List of values which get populated in the comb-box for the field "Status" on the SC screen when i click on the "CHECK STATUS" link.
I need to delete some of these entries which appear in the combo-box.Can anyone tell me how this can be done(partcularly with some info on how these values are getting populated and from where?).Points will be awarded.
Thanks & regards,
Disha.Hi Disha,
you will have to change standard ABAP code for this.
SC status list for CHECK STATUS is build in FORM status_mixed_text_fill in include LBBP_PDH_SEARCHF27.
Rgds
Christophe
PS: please reward points for helpfull answers -
How validate a combo box generated for a selectOne on javascript
Hi!!
I have a question!
i need how validate a combo box on javascript if this is generated by selectOne
for example:
<tr>
<td width="150px"><b>Cantidad a elegir:</b></td>
<td><f:selectOne att='idisponibilidad.cantidadElegir' type='combo'/></td>
</tr>
this is an form and this generates in the name of the select:
<select name="$FO$idisponibilidad.cantidadElegir">
<option value="0">..</option>
<option value="4">..</option>
</select>
but now I try to do this:
document.form.$FO$idisponibilidad.cantidadElegir.value
and obviously does not work!!!
someone knows how to validate
Thanks!!!Taking Mark's Code .. add an id
<select id="personGender" <f:fieldName att="person.gender"/>>
<c:forEach var="gender" begin="0" items="${genders}" varStatus="status">
<c:choose>
<c:when test="${person.gender == gender}">
<option value="<c:out value="${gender}"/>" selected="true"><c:out value="${gender}"/></option>
</c:when>
<c:otherwise>
<option value="<c:out value="${gender}"/>"><c:out value="${gender}"/></option>
</c:otherwise>
</c:choose>
</c:forEach>
</select>
Add an id to above code. In your submit button write a function on onclick event .. like onclick="submitForm()"
Write the functions as :
function submitForm(){
if(validateFileds()){
document.<your form id>.submit();
function validateFields(){
if (isEmptyCombo ('personGender')) {
alert ( "'Selecting a gender is mandatory" );
focus('personGender');
return false;
function isEmptyCombo (id) {
var combo = document.getElementById(id);
return combo != null && combo.options[combo.selectedIndex].value == "";
function focus (id) {
if (document.getElementById(id)) document.getElementById(id).focus();
Thanks,
Karmaresh
Edited by: user856811 on Mar 15, 2010 9:22 PM
Edited by: user856811 on Mar 15, 2010 9:22 PM -
How to populate the second combo box by depending on the selection in 1st?
I have two combo boxes, both of data in the lists come from the database. The list in the second will be changed when the selection is changed in the first one. I am trying to do query again in the ActionPerform function, unfortunately the list in second one doesn't change.
I am learning Swing now, I really appreciate for any suggestions!
Thankscamickr,
I have another question for the tab pane. Now I have to remove the tab and add tab for updating the tab pane. I wonder if there is other way to do it. I really appreciate your help!
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import java.net.URL;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
public class test_tabpane extends JPanel implements ActionListener {
private JPanel MainPane;
private JComboBox combobox2;
private JTabbedPane TabbedPane;
private JComponent panel1;
private JComponent panel2;
private String [] resources ={"ZZAA", "ZZAB", "ZZAC", "ZZAD"};
private String selected_resource = "";
public test_tabpane() {
MainPane = new JPanel();
MainPane.setOpaque(true);
MainPane.setPreferredSize(new Dimension(600, 70));
MainPane.setBorder(BorderFactory.createRaisedBevelBorder());
combobox2 = new JComboBox(resources);
combobox2.addActionListener(this);
MainPane.add(combobox2);
add(MainPane);
UIManager.put("TabbedPane.tabInsets", new Insets(5,5,5,5));
TabbedPane = new JTabbedPane();
panel1 = makeTextPanel(resources[0]);
TabbedPane.addTab("Language/Notes", panel1);
panel2= makeTextPanel(resources[0]);
TabbedPane.addTab("Relations/Coverage", panel2);
TabbedPane.setPreferredSize(new Dimension(600, 340));
TabbedPane.setFont(new Font("ariel", Font.BOLD, 11));
TabbedPane.setSize(600, 340);
add(TabbedPane);
protected JComponent makeTextPanel(String text) {
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
// panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
public void actionPerformed(ActionEvent e) {
JComboBox cb = (JComboBox)e.getSource();
if ("comboBoxChanged".equals(e.getActionCommand()))
// if ("comboBoxEdited".equals(e.getActionCommand()))
// System.out.println("in action:" + (String)cb.getSelectedItem());
String selected_string = (String)cb.getSelectedItem();
StringTokenizer st = new StringTokenizer(selected_string, "|");
selected_resource = st.nextToken();
updateTabbedPanes(selected_resource);
protected void updateTabbedPanes(String selected_string) {
panel1 = makeTextPanel(selected_string + " in Language/Notes");
int index = TabbedPane.indexOfTab("Language/Notes");
TabbedPane.remove(index);
TabbedPane.insertTab("Language/Notes", null, panel1, "", index);
panel2 = makeTextPanel(selected_string + " in Relations/Coverage");
index = TabbedPane.indexOfTab("Relations/Coverage");
TabbedPane.remove(index);
TabbedPane.insertTab("Relations/Coverage", null, panel2, "", index);
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
private static void createAndShowGUI() {
JFrame.setDefaultLookAndFeelDecorated(false);
//Create and set up the window.
JFrame frame = new JFrame("test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
JComponent ContentPane = new test_tabpane();
ContentPane.setOpaque(true); //content panes must be opaque
frame.setContentPane(ContentPane);
//centers a frame onscreen // it is a problem for wide screen
// frame.setLocationRelativeTo(null);
frame.setLocation(300, 120);
frame.setSize(1024, 768);
frame.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
//Display the window.
frame.pack();
frame.setVisible(true);
* @param args
* This is main function.
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
} -
VBA Userforms – Getting errors when item from combo box is not selected
Hi there
Thank you in advance for taking the time to check this out.
Objective:
I have 2 combo boxes, one is dependent on what has been selected in the first combo box (dynamic named range), they work fine except for an irritating error when the user accidentally clicks in the empty
Cmbox_IncCategory and it won’t allow the user to go back to the
cmbx_Category_Type box if the user forgot he had to make a selection from that first before selecting the
Cmbox_IncCategory.
The error that pops up is “Invalid property value”.
I tried having text in there to say “please select from Cmbox_IncCategory first, but that didn’t fix it.
I tried to ‘If error resume next’ but that didn’t like it either. Now I am stumped.
Main combo box= cmbx_Category_Type
2nd combo box (displaying a list dependent on what was selected in Main combo box)= Cmbox_IncCategory
I know there must be a way to fix it so that if a user clicks on the combo box, but doesn’t make a selection it won’t lock up the form.
Yes, it is a mandatory field, and I was considering using a message box to advise the user that this must be completed, but I am not sure how to do it (and avoid the errors
Here’s the current code I have for the combo boxes.
Me.Cmbox_IncCategory = "" 'Clears the contents of the 2nd combobox when another category is chosen
On Error Resume Next
'I can't seem to have the Incident Category combobox to be empty when the form is open _
I have tried Cmbox_IncCategory.Value = "", but I get an error. I then tried Cmbox_IncCategory.text = "" _
but also get the error. I don't know how else to get it to work .. I tried both codes in the _
form_initialize, but get an error ... I'm stumped !
Select Case Me.cmbx_Category_Type
Case "Crime"
Me.Cmbox_IncCategory.RowSource = "Inc_Cat_CRIME"
Case "Property Damage - Minor - NS"
Me.Cmbox_IncCategory.RowSource = "Inc_Cat_PROPRTY_NS"
Case "Property Damage - Significant - S"
Me.Cmbox_IncCategory.RowSource = "Inc_Cat_Proprty_S"
Case "Safety"
Me.Cmbox_IncCategory.RowSource = "Inc_Cat_SAFETY"
Case "Security Breach"
Me.Cmbox_IncCategory.RowSource = "Inc_Cat_BREACH_S"
Case "Support"
Me.Cmbox_IncCategory.RowSource = "Inc_Cat_SUPPORT"
Case "Vehicle"
Me.Cmbox_IncCategory.RowSource = "Inc_Cat_VEHICLE_S"
End Select
End Sub
I’d be really grateful if someone could help me out, or perhaps direct me to where I might find some coding that will achieve the result I am seeking.
This links to
My Sample form
With much gratitude,
TheShyButterfly
Hope you have a terrific day, theShyButterflyHi Peter,
Thank you for your quick response :) Brave man! :)
Both combo boxes are blank to start with (because nothing has been selected). If I click on the first combo box (cmbx_Category_Type) which lists the main events/category types, but I don't select any thing, and I click in the secondary box
(Cmbox_IncCategory) and then click on any other control, I get an “Invalid property value” error. When I click OK on the error (a few times) and I return to the code window, it gives no indication where/what is breaking
the code/causing the error. I have no choice but to exit the form by stopping in the code window.
If I click on the first textbox, (cmbx_Category_Type), and then do the right thing and make a selection, then I have no problems with the secondary textbox (Cmbox_IncCategory).
As I am not that up on VBA I am trying to follow your instructions... I have changed the code as follows, removed and replaced the rowsource name, but I encounter the very same problem.
When I changed my code from Me.Cmbox_IncCategory="" to yours myCombo.ListIndex = -1 (changing the combo box name to reflect my combo box name) and adding the second line of code ...
Me.Cmbox_IncCategory.ListIndex = 0 I still got the same behaviour and error.
I even tried moving each row of the named rows down one row (so that there would be a 'blank' row which could be selected to get out of trouble, but it wasn't very successful either.
Have you opened my form to see what happens, I included the link so whoever was looking at my problem (and yes, I have many I know), could see for themselves what it is doing/not doing.
The code now reads as below (is this what you meant?) - the results were as I mentioned above.
Me.Cmbox_IncCategory.ListIndex = -1 'Clears the contents of the 2nd combobox when another category is chosen
Me.Cmbox_IncCategory.ListIndex = 0
' On Error Resume Next
'I can't seem to have the Incident Category combobox to be empty when the form is open _
I have tried Cmbox_IncCategory.Value = "", but I get an error. I then tried Cmbox_IncCategory.text = "" _
but also get the error. I don't know how else to get it to work .. I tried both codes in the _
form_initialize, but get an error ... I'm stumped !
Select Case Me.cmbx_Category_Type
Case "Crime"
Me.Cmbox_IncCategory.RowSource = "Inc_Cat_CRIME"
Case "Property Damage - Minor - NS"
Me.Cmbox_IncCategory.RowSource = "Inc_Cat_PROPRTY_NS"
Case "Property Damage - Significant - S"
Me.Cmbox_IncCategory.RowSource = "Inc_Cat_Proprty_S"
Case "Safety"
Me.Cmbox_IncCategory.RowSource = "Inc_Cat_SAFETY"
Case "Security Breach"
Me.Cmbox_IncCategory.RowSource = "Inc_Cat_BREACH_S"
Case "Support"
Me.Cmbox_IncCategory.RowSource = "Inc_Cat_SUPPORT"
Case "Vehicle"
Me.Cmbox_IncCategory.RowSource = "Inc_Cat_VEHICLE_S"
End Select
End Sub
I appreciate your patience :) I am growing in knowledge, but its a slow process. Please let me know if there is anything else I can help clarify for you :)
This links to
My Sample form
Thanking you again
TheShyButterfly
Hope you have a terrific day, theShyButterfly
Maybe you are looking for
-
I recently started using an iPad. I up loaded several apps. Evernote, cloudon, Goodreader, Drop Box and lots of others. It crashes when I down load pictures and then try to use them. Converting a jpg to a pdf usually triggers a crash. Is there a "hit
-
Just upgraded to iOS 7 and my Instagram will no longer connect to Twitter
I get an error message saying "We couldn't connect to Twitter. If you see this error repeatedly, tap Learn More to visit our Help Center." The help center only offers solutions for iOS 5 & 6. I've already confirmed that Instagram is set to use Twitt
-
Hi Friends, I am creating archiving object for FI_DOCUMNT,while defining archiving object there is field write program. So here which name we have to give for write and delete programs?Is there any predefined programs for this? can any one please h
-
Unable to use Shockwave Player - Xtra error
I am unable to run Shockwave - I keep getting the following error messages: "This application requires an Xtra (Font, Flash Movie, Text ...) that either does not exist or failed to initialize properly. Please make sure the appropriate Xtras are in t
-
I have a string of a textarea with enters in it. How can I replace the enters of this string into <br>? I know that you can do it in php with the function nl2br(). tnx