Hey Everyone,
Well i don't know if my question should be in javascript/ajax or coldfusion, i figure this is more of a coldfusion question. But if this is in the wrong section let me know an all gladly delete my question an put it in the correct section.
Well what i am trying to do is pretty simple. I have a input field and someone starts typing in a customer number. As they type in the customer number the drop down box is populated. They then click on the drop down box an the rest of the form is populated (it gets all the information from a database).
I found a script online that does almost exactly what i want to do except it is in php. I have found an example of this in every language except coldfusion and well i must admit i am not good at converting code from one language to another.
But anyway i was wondering if anyone could provide me with an example on how i would do this in coldfusion instead of php? or if you know of a tutorial,forum, or example online i could look at?
Here is the example page
an here is the code
i already created the drop down box part of this (since it is missing in the
the example above), but like i said i just can't figure out how i would populate it using my coldfusion database. Here is what i got for the drop down box
here is coldfusion/html
here is the javascript
But thank you in advance :),
Rach
Well i don't know if my question should be in javascript/ajax or coldfusion, i figure this is more of a coldfusion question. But if this is in the wrong section let me know an all gladly delete my question an put it in the correct section.
Well what i am trying to do is pretty simple. I have a input field and someone starts typing in a customer number. As they type in the customer number the drop down box is populated. They then click on the drop down box an the rest of the form is populated (it gets all the information from a database).
I found a script online that does almost exactly what i want to do except it is in php. I have found an example of this in every language except coldfusion and well i must admit i am not good at converting code from one language to another.
But anyway i was wondering if anyone could provide me with an example on how i would do this in coldfusion instead of php? or if you know of a tutorial,forum, or example online i could look at?
Here is the example page
an here is the code
i already created the drop down box part of this (since it is missing in the
the example above), but like i said i just can't figure out how i would populate it using my coldfusion database. Here is what i got for the drop down box
here is coldfusion/html
Code:
<cfquery name="getcustnum" datasource="CustomerSupport"> usp_CS_Getcontacts </cfquery> <HTML> <HEAD> <TITLE>JavaScript Toolbox - Auto-Complete</TITLE> <SCRIPT LANGUAGE="JavaScript" SRC="autocomplete.js"></SCRIPT> </HEAD> <BODY BGCOLOR=#FFFFFF LINK="#00615F" VLINK="#00615F" ALINK="#00615F"> <FORM> Customer Number* <INPUT TYPE="text" NAME="input1" VALUE="" ONKEYUP="autoComplete(this,this.form.options,'value',true)" onChange="validate(this.form.custnum,'Customer Number')"> <SELECT NAME="options" onChange="this.form.input1.value=this.options[this.selectedIndex].value" onclick=""> <cfoutput query="getcustnum"> <option value="#fk_custNum#">#fk_custNum#</option> </cfoutput> </SELECT> Company Name:<input type="text" name="compname" size="20" id="compname"/> First Name:<input type="text" name="fname" size="20" id="fname"/> Last Name:<input type="text" name="lname"size="20" id="lname"/> </FORM> </BODY> </HTML>
here is the javascript
Code:
function autoComplete (field, select, property, forcematch) { var found = false; for (var i = 0; i < select.options.length; i++) { if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) { found=true; break; } } if (found) { select.selectedIndex = i; } else { select.selectedIndex = -1; } if (field.createTextRange) { if (forcematch && !found) { field.value=field.value.substring(0,field.value.length-1); return; } var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;"; if (cursorKeys.indexOf(event.keyCode+";") == -1) { var r1 = field.createTextRange(); var oldValue = r1.text; var newValue = found ? select.options[i][property] : oldValue; if (newValue != field.value) { field.value = newValue; var rNew = field.createTextRange(); rNew.moveStart('character', oldValue.length) ; rNew.select(); } } } }
Rach
Comment