473,386 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

I want to fill budget code field when the department is selected in the combo box

4
I have table departments with three fields DeptID, DepartmentName and budgetcode. Departments value are populated in the dropdown menu. i need to fill the text box of budgetcode when department is selected.

here is code for departmentlist is populated

Expand|Select|Wrap|Line Numbers
  1. <select name="Department" id="Department" onChange="showText();">
  2.                 <option value="notselected" selected>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
  3.                 <%
  4.     set rs1=server.createobject("adodb.recordset")
  5.     DepartmentSQL="Select DeptID,DepartmentName,bcode from departments order by Departmentname"
  6.  
  7.     rs1.open DepartmentSQL,cn,3
  8.  
  9.     while not rs1.eof
  10.                  DepartmentID=rs1("DeptID")
  11.                  DepartmentName=rs1("DepartmentName")
  12.                  bcode=rs1("bcode")
  13.             %>
  14.                 <option value="<%=DepartmentName%>"><%=DepartmentName%></option>
  15.                 <%rs1.movenext
  16.       wend
  17.  
  18.      %>
  19.               </select>
Jun 24 '13 #1
6 1343
Dormilich
8,658 Expert Mod 8TB
that us usually done through AJAX. you fetch the data by using the selected value and insert the returned data in your output container.
Jun 24 '13 #2
moiz20
4
Can you please write it here to help me out
Jun 24 '13 #3
Dormilich
8,658 Expert Mod 8TB
I can help improve your code.
Jun 24 '13 #4
moiz20
4
Please it would be great!
Jun 24 '13 #5
Dormilich
8,658 Expert Mod 8TB
show us what you tried.
Jun 24 '13 #6
moiz20
4
The function i am using to fill the value but it is not working.
Expand|Select|Wrap|Line Numbers
  1. function showText()
  2.       {
  3.  
  4.         //This functions is used show selected value of listbox into textbox.
  5.          var objselect;
  6.          var txtval;
  7.         objselect=document.forms['form1'].Departments;
  8.  
  9.        //Get the selected value from listbox
  10.         txtval=objselect.options[objselect.selectedIndex].value;
  11.  
  12.        //Display it in textbox 
  13.         document.getElementById('Budget_Code').value = txtval; 
  14.       }
The database is in access
Departments table there are three field. DeptID, DepartmentName and bcode.
Here is the code for department list
Expand|Select|Wrap|Line Numbers
  1. <select name="Department" id="Department" onChange="showText();">
  2.                 <option value="notselected" selected>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
  3.                 <%
  4.     set rs1=server.createobject("adodb.recordset")
  5.     DepartmentSQL="Select DeptID,DepartmentName,bcode from departments order by Departmentname"
  6.  
  7.     rs1.open DepartmentSQL,cn,3
  8.  
  9.     while not rs1.eof
  10.                  DepartmentID=rs1("DeptID")
  11.                  DepartmentName=rs1("DepartmentName")
  12.                  bcode=rs1("bcode")
  13.             %>
  14.                 <option value="<%=DepartmentName%>"><%=DepartmentName%></option>
  15.                 <%rs1.movenext
  16.       wend
  17.  
  18.      %>
  19.               </select>
Jun 24 '13 #7

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

Similar topics

7
by: jballard | last post by:
Hello, I have a database set-up with a form and two subforms in it. I have one of the subforms (replacement parts) set-up where you can pick part numbers from a drop down box and also pick a...
3
by: euphorica | last post by:
I am making an inventory database. I have a field InventoryNumber where I put a specific code. The code always starts with a particular letter. I would like to fill in another field with...
3
by: Steve Yerkes | last post by:
There seems to be way too much confusion over how to set focus on the a field using a field validator. I looked all over the web and found people trying to do this, but not getting anywhere. There...
6
by: MROPARTNER | last post by:
I have a field in a form called "Date" I am looking to fill this text field with the current date. Is there a way to do this with ASP or an easier way? Thanks Bill
4
by: rsine | last post by:
The company I work for owns several domain names for which email aliases have been created. For example, a user may have a primary address of bob@xyz.com and an alias of bob@wxy.com. Our...
2
by: bkunjitam | last post by:
Hi, I am using Python 2.5. I have an entry field and a radio button. I need to disable the entry field when the radio button is selected. How do i change the state to DISABLED in run time. ...
1
by: imwhiteandnerdy | last post by:
i'm hoping I can get some help with adding my combo box selection to my access database.Any Help would be appreciated. I've been told I need complex binding Basically I just want to add the...
2
by: mckurban | last post by:
Hi All, I'm not very familiar with Javascript and need help with setting up some javascript code to allow users to create dynamic radio buttons from text field and then to use selected radio value...
1
by: bytenut | last post by:
I would like to display two field values in a combo after selecting from the list items... i.e. my drop-down shows two fields from a lookup, but when I select the item, only the first field value is...
3
by: Ron Mowry | last post by:
I am wanting to create a macro that will fill a specific field on a form and then go to the next record set. I have a blank field in the table that the form is pulling from. I want the user to be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
Oralloy
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,...

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.