By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,115 Members | 843 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,115 IT Pros & Developers. It's quick & easy.

Need to access the selection made by the user from selection control

P: 1
I have two selection controls and based on the selection made by the user i need to pass those values to the other program in java......

can u give me the way......
Aug 8 '07 #1
Share this Question
Share on Google+
2 Replies

10K+
P: 13,262
I have two selection controls and based on the selection made by the user i need to pass those values to the other program in java......

can u give me the way......
You need to explain more clearly what you have.
Do you have two Java programs running on the same JVM?
Aug 8 '07 #2

100+
P: 127
Hi subbaraju,

welcome to TSDN. You can very well do it by getting the value from the controlbox and putting it inside.

The select box (in HTML control) has some properties

(*) selectedIndex -> the index of the item/option presently selected
(*) value -> the value of the item being selected.

Let's say you have a select box which gets rendered like this..

Expand|Select|Wrap|Line Numbers
  1. <select id="mySelectBox">
  2. <option value="v1">ABC</option>
  3. <option value="v2">DEF</option>
  4. </select>
  5.  
You can make a JavaScript function get executed on changing the value of the select box by calling it in the 'onChange' property. Inside the javascript function, you can get it by accessing

Expand|Select|Wrap|Line Numbers
  1. var index = document.forms[0].mySelectBox.selectedIndex;
  2. var selValue = document.forms[0].mySelectBox.value;
  3.  
Here the index would be '1' and value would be 'v1' if you have chosen the 'ABC' in the list box.

Get the value in a hidden variable and submit it to a page where you can retrieve the value from the 'request' scope.

Hope this helps!
Aug 8 '07 #3

Post your reply

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