Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to populate a box based on an access database value

Status
Not open for further replies.

willz99ta

IS-IT--Management
Sep 15, 2004
132
US
Thanks for your help,

I am going to describe my layout and then describe what i am trying to do -- I really don't even know if there is a way to do this.

Layout:

--------------------------------------
Name Text box the user enters |
--------------------------------------

--------------------------------------- --------------------
DeptCC Text box the user enters| |Find DeptCC Button|
--------------------------------------- --------------------

-------------------------------------------------------------------
ConfirmDir based on an Access data on same row as DeptCC|
-------------------------------------------------------------------

-----------------------
Submit Entire Form|
-----------------------

Description:
What is the easiest way to have the page lookup the director in Access based on the DeptCC user entered text box --- and then be able to submit the whole form into another page.


Thanks for your help,
Will

 
With help from codingforums I used a hidden iframe to fix the form:


Example:

Code
<form name="MainForm" method="post" action="whatever.asp">
<input name="theName">
<input name="DeptCC"
onchange="document.getElementById('HIDE').src='getDir.asp?deptcc='+this.form.DeptCC.value;">
<input name="Director" readonly>
...
<input type=submit>
</form>
...
<iframe id="HIDE" style="display: none;"></iframe>
...And then your getDir.asp code looks like this:

Code:
<%
deptcc = Replace(Trim(request("deptcc")),"'","''")
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "...."
Set rs = conn.Execute("SELECT Director FROM yourtable WHERE deptcc='" & deptcc & "'"
director = "[not found]"
If Not rs.EOF Then director = rs(0);
rs.Close
conn.Close
%>
<script>
window.parent.document.MainForm.Director.value = "<%=director%>";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top