|
Creating an image preview using JQuery and a select form field |
This article will deal with a user choosing a value from a Select field, and that selection being passed to a JQuery handler. The JQuery handler will perform an AJAX request to a CFC, which will return a JSON value (URL String) that we will use to populate an img html tag.
In this way when you select different options from the select field drop down, the image changes inline, without any page reloads.
|
Integrating Google search into your site using ColdFusion and XML |
This article examines how you can create and integrate a Google site search into your site. We will query Google and return an XML packet, which we will translate and display within our sites framework.
|
Returning values from mySQL in a select query as Yes/No rather than 1/0 |
Whilst writing a ColdFusion based query to create a JSON response I thought I'd look up returning data values as a "Yes/No" string rather than "1/0". Then I wouldn't have to transform it in any way to use in the JSON build script.
The mySQL version allows you to do this by evaluating the value, and matching a string if the condition is met, like this:
2SELECT intid,varuserfname,varusersname, IF(intactive<>0, "Yes", "No")
3FROM table.users
This does not work in ColdFusion at all. An error is thrown:
After a little tweaking it seems that if you alias the field it does work. In the example code below I've simply aliased the field with its own name.
I'm not exactly clear why, as the error message above isn't all that helpful.
2SELECT intid,varuserfname,varusersname, IF(intactive<>0, 'Yes', 'No') as intactive
3FROM table.users
|
Combining persistent server side (ColdFusion) variables with client side (JQuery) values |
I stumbled upon an interested dilemma recently whilst building a search engine. The results of a search are returned, and can be viewed in a list or thumbnail view. The view toggle is a uses a JQuery function, so no persistent data is stored concerning a users current viewing option. The dilemma is how do you maintain the viewing mode across page reloads, such as for pagination, or filtering of the search results?