471,886 Members | 1,090 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

select value from a combobox and display in a textbox

274 100+
I have a simple query. I have a dynamic combobox when I select one value fromt he combobox; on click a function is called that display the value of the combobox(i.e not same as text list of combobox) in textbox on the form.
I want to display the selected entry(not the value) of the combobox in another text box. How I can do that
this is what I already have
Expand|Select|Wrap|Line Numbers
  1. function getvalue(form)
  2.        {
  3.          form.clientID.value=form.clientName.value;
  4.          form.ClientName.value=form.clientName.selected; // whatever is there is combobox display it textbox called ClientName.
  5.        }
Jun 5 '08 #1
7 4725
971 Expert 512MB
I am not familiar with VB, but this looks like VB code and therefore should belong in that forum. If I am correct on the code I will move this post for you.

Jun 6 '08 #2
274 100+
it's javascript. you cam move it there.
Jun 6 '08 #3
5,390 Expert Mod 4TB
you should post the relevant html-code too, so that we may see whether the ids and names are correct. you may even consider to use dom-methods like document.getElementById(); for your node-references ...

kind regards
Jun 6 '08 #4
274 100+
I got it working thanks
Jun 10 '08 #5
16,027 Expert Mod 8TB
That's good to hear, but it's always courteous to post how you solved it for the benefit of others.
Jun 11 '08 #6
274 100+
I used a very simple technique:
I used BEAN to get value of the table client and displayed clientName as text of the combobox and used clientID as the value of the combo.

Expand|Select|Wrap|Line Numbers
  1. <select name="clientName" id ="clientName" onChange="getvalue(this.form)">   
  2.     <% java.util.Vector clients = (java.util.Vector)session.getAttribute("clients");
  3.     if(clients != 
  4.                { // start of if1
  5.                           for (int i =0; i<clients.size(); i++)
  6.                           { //start of for1
  7.                             Client client = (Client)clients.get(i
  8.               if(client instanceof Client)
  9.                {// start of if2
  10.                  %>
  11.           <option value=<%= client.getClientID() %>>
  12.                          <%= client.getClientName() %>  </option>
  13.             <%
  14.      }// end of if2
  15.               }// end if for1
  16.            }// end of if1
  17.         %>
  19.             </select> 

Again in the function getvalue() I tried something like this

Expand|Select|Wrap|Line Numbers
  1. function getvalue(form)
  2.        {
  3.          form.clientID.value=form.clientName.value;
  4.        }

It works fine and good thing is it's easy.
Jun 16 '08 #7
16,027 Expert Mod 8TB
Thanks for posting the solution.
Jun 16 '08 #8

Post your reply

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

Similar topics

14 posts views Thread by Jos? | last post: by
5 posts views Thread by jmDesktop | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

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.