473,834 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

select value from a combobox and display in a textbox

274 Contributor
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 4894
971 Recognized Expert Contributor
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 Contributor
it's javascript. you cam move it there.
Jun 6 '08 #3
5,390 Recognized Expert Moderator Expert
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.getEle mentById(); for your node-references ...

kind regards
Jun 6 '08 #4
274 Contributor
I got it working thanks
Jun 10 '08 #5
16,027 Recognized Expert Moderator MVP
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 Contributor
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 Recognized Expert Moderator MVP
Thanks for posting the solution.
Jun 16 '08 #8

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

Similar topics

by: Jos? | last post by:
This one droves me completely mad. I did not succeed to exploit the track given to me by Bob. I have : three tables : Clubs, Persons and ClubsPersons that join the two first in a many to many relationship. Club has two (2) fields : ClubId (Autonumber) and ClubName (Text). Peoples has two(2) fields : (PersonId (Autonumber) and PersonName (Text) ClubsPersons has two (2) fields : ClubId (LongInteger) and PersonId
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the combobox. What is the solution? Thank you in advance.
by: Susan Bricker | last post by:
The following error: "The current field must match the join key '?' in the table that seves as t the 'one' side of one-to-many relationship. Enter a record in the 'one' side table with the desired key value, and then make the entry with the desired join key in the 'many-only' table." ... happens when I click on an entry of a combobox. HELP!! Here's the background:
by: sathyan8294 | last post by:
i am using dotnet 2003.i am doing my project in vb.net windows application.i have two form in my project.first form is datagrid .In second form label,textboxes and combobox are avilable to save the entering values in datagrid of first form through this 2nd form.my problem is,i want to search a value using combobox. for example, in first form, there are 4 columns named as name,age,rollno,address in datagrid. values are ramu for namecolumn,24...
by: DesCF | last post by:
I have a textbox and a combobox on a toolstrip. The user enters either an ID in the textbox or selects a name from the combobox. When the user selects a name from the combobox the textbox is filled in automatically by setting its .Text property equal to the .SelectedValue of the combobox. When the user enters an ID in the textbox the combobox's .SelectedValue is set to the .Text value in the ID textbox. All works fine but it is ...
by: billypit | last post by:
Hi, I am totaly new to MS Access. I have one form in MS Access in which i want that whenever i select an item from combobox then in the textbox on the same form or subform i want value from table based on selection from combobox. like in my table there two fields ID,name 1 billy 2 sandy
by: billa856 | last post by:
Hi, I want to know how can we set the value of Textbox = value of field in table when we select a value form combobx. example i have a table customer CID CNAME CSALARY 1 Billa $5500
by: vishnu2008 | last post by:
I am using MS Access (frontend), VB 6.0 (code) and SQL Server (DB) now. I have a combobox and textbox. I need to select multiple items from combobox which should be displayed in textbox. Items should be displayed line by line but not in the same line. Please help. Here is the code which I have coded.Private Sub cmbpocomments_click() If Len(txtcocomments.Value) > 0 Then Dim a As String a = txtcocomments.Value ...
by: jmDesktop | last post by:
I know this should be straight forward, but I have not gotten it yet. I have a combobox and a textbox. I want to display what is selected in the combobox in the textbox. I have: txtMyTextBox.Text = cboMyBox.SelectedText; //is this right? But it never shows up. I tried SelectedValue, and SelectedValue.
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.