We help IT Professionals succeed at work.
Get Started

Javascript - get data from db on form fill x 2

movieprodw asked
Last Modified: 2013-12-12

I am using the below code to get the information form the database and it works fine. The issue is that I want to do it twice, I want to do it as it is to find the client data phone/address/etc as well as fine the city state when the zip is entered.

So what I need is so that I can name another field 'zipData' instead of ClientID. I did try to copy and paste the code I am using and changed the all of the instances where is said ClientID to zipData and it will not work.

I would love any help.
<script type="text/javascript" src="js/ajax.js"></script>
	<script type="text/javascript">
	Ajax client lookup
	Copyright (C) 2006  DTHMLGoodies.com, Alf Magne Kalleland
	This library is free software; you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public
	License as published by the Free Software Foundation; either
	version 2.1 of the License, or (at your option) any later version.
	This library is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	Lesser General Public License for more details.
	You should have received a copy of the GNU Lesser General Public
	License along with this library; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
	Dhtmlgoodies.com., hereby disclaims all copyright interest in this script
	written by Alf Magne Kalleland.
	Alf Magne Kalleland, 2006
	Owner of DHTMLgoodies.com
	var ajax = new sack();
	var currentClientID=false;
	function getClientData()
		var clientId = document.getElementById('clientID').value;
			currentClientID = clientId
			ajax.requestFile = 'getClient.php?getClientId='+clientId;	// Specifying which file to get
			ajax.onCompletion = showClientData;	// Specify function that will be executed after file has been found
			ajax.runAJAX();		// Execute AJAX function			
	function showClientData()
		var formObj = document.forms['clientForm'];	
	function initFormEvents()
		document.getElementById('clientID').onkeyup = getClientData; // If you wish to have a lookup "as you type"
	window.onload = initFormEvents;

Open in new window

Watch Question
Project Manager
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE