I needed a way to check a database when someone enters a code into a form 
field, and I ran across an old posting from Ray Camden using SPRY assets to 
accomplish this. (I know that I should probably use AJAX or jQuery, but I have 
not learned these languages yet so I am stuck going off of what I can find on 
line).
Anyway, when I enter a code into the field, I get an error Exception caught 
while loading checkcode.cfm?orgname=AA; Cannot set property 'innerHTML' of null.

Here is the code below:

<script>
        Spry.Data.Region.debug = true;

        function checkorgname() {
        
                var uvalue = document.getElementById("orgname").value;
                        if(uvalue.length < 2) { status(''); return; }
        
                
Spry.Utils.loadURL("GET","checkcode.cfm?orgname="+encodeURIComponent(uvalue), 
false, orgcheck);
        }
        
        function orgcheck(request) {
        
                var result = request.xhRequest.responseText;
        
                if(result == 0) status('You have entered an invalid code. 
Please try again!');
                 else status('');
        
        }
        
        function status(str) {
        
                var resultblock = document.getElementById("resultblock");
                        resultblock.innerHTML = str;    
        
        }
</script>

form field in question:

 <input type="text" name="orgname" id="orgname" size="10" required 
class="upper" onKeyUp="checkorgname();"  />

The checkcode.cfm page works fine though. When I call it on it's own I get 
either a 0 or 1 depending if the orgname in the URL variable is in the database.


Thanks,

Bruce

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:353556
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to