Is it possible to execute a CFQuery onBlur of a form field?? I don't want to read the whole table, and I'd like to do a query using the value entered, to validate if it exists.
You have to use a little trickery to make this work but I think it can be done. Here's what I suggest:
1. Trigger a function with onblur.
2. In this function, create a new image and set it's source attribute to be a CF script.
3. Inside the CF script, do your query and then use the <cfcontent> tag to return an image.
4. Based on the output of your query, return one of two different images that have a different size. One image indicates valid, the othe indicates in-valid.
5. Inside the js function, check the image.complete value to determine when it's fully loaded.
6. Determine which image was sent back by examining the image.height value.
7. I would use a 1x1 gif and a 1x2 gif so they'll load really fast. If the height is 1, the query indicates it's valid, if it's 2, the value is in-valid.
I've never tried this so let me know how it turns out.
GJ
Since you're relying on the JS onblur function, I assume it's safe to implement a partial JS solution. Since you want to execute a query, you're going to have to run a CF script on the server.
The easiest way I know to do this from the clientside WITHOUT causing a page refresh is to create a new image and set it's source to a CF script (
This causes JS to request the CF script because it thinks it's requesting an image. This is why you use <cfcontent> to return an image as JS will retrieve the image even though it never displays it.
This is the same concept as hover over effects where JS downloads an image to display when you put your mouse over a button. Once the client side JS requests the script file (thinking it's retrieving an image), it will download a valid gif file which you can check the dimensions of to determine the results of the query.
There is one problem with this approach which I'll wait to mention until you have this part working as it would only confuse the issue.
I am stumped.....
I have to admit, I'm pretty new at all this. This is what I have so far, but it's not liking my code AT ALL. I would really appreciate a debugger right about now.
Anyway, I'm going to keep playing with this, but just in case I'm WAY off, I thought you would be able to tell me. I really want to figure this out, but if you see I'm going in the wrong direction - I can rethink this!!!
It keeps telling me I have a syntax error on my "document.acct_info.A_ACCT_GROUP.focus();" line. Also, when I try using it, it says object expected.
Here's some code:
(testIt.cfm)
<CFOUTPUT>
<SCRIPT language="JavaScript">
function valAcctGrp(AG)
{
var AcctGroup = AG.value.toUpperCase();
<IMG SRC="
due to time constraints, I had to stop trying this method. I ended up adding another .cfm file (much to my dismay) to run the query against the form.value. If there is a problem I take them back to the form, otherwise I proceed to the next file.
Hopefully I'll get some time soon to play with it, because I think it can work. This would work around a problem I think more people could be getting hung up on besides me.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.