-
Categories
-
Monthly Archives
Tag Cloud
Feeds
-
Blog Lounge
-
Recent Comments
- LeanneMassey: Don't you acknowledge that this is correct time to get the <a...
- goldpreis: I don't have to check to see if a directory exists first.thanks.
- JulietSantos23: This post is very true. But how to stop comment spamming? Because <a...
- GEENAMV: People do opine that the essay papers writing is the really time taking thing....
Links
Links
Gary F wrote on 06/17/09 1:17 PM
Nice. Is the structure of the survey stored in an array or XML (no formatting or HTML!) that can be passed to CF to store in a db, then later use to re-create the survey? Thanks.Gary F wrote on 06/17/09 1:40 PM
Me again. Some suggestions if that's okay... It would be useful if the order of the questions can be changed. When you've created a few you might changed your mind about the order they're being asked in. Perhaps drag them up or down the page to the desired location? Or have an up/down set of buttons on each question if it's easier to code.How about displaying the question or the question number at the top of each panel so you can easily identify each question when the panels are minimised? If you've got 20+ questions it's tricky to quickly review or find them.
spiraldev wrote on 06/17/09 2:25 PM
@Gary I am storing the data in a couple of tables one holds the survey name description then a table to hold the question info and a table that stores the options of the questions.@Gary
Great ideas I planned on doing both, the drag and drop and have the title bar show the question.
Gary F wrote on 06/17/09 6:25 PM
You're storing the data in HTML tables or db tables? If db tables then that sits outside of the jQuery plugin, so what format is the data in that gets passed back from your plugin to the server? Can you demo this here please if it's not too much trouble? Thanks.Gene wrote on 07/23/09 12:47 AM
Hi,I am looking for a form builder at the moment and was wondering whether you wanted to collaborate.
Cheers
Gene
norman wrote on 07/31/09 1:15 PM
look at this, it's very cool, can you take some ideas from here http://www.phpform.orgJames wrote on 09/03/09 1:47 PM
First off, Link to Source Not Working...Secondly, might want to look at jotform.com that a pretty sweet system they got there.
Gary F wrote on 09/03/09 2:09 PM
@James, the form builder at jotform.com is the best I've seen as far as the GUI goes, very comprehensive. However, all it does is generate HTML. It does not create an XML interpritation of the form nor any other data that an application can use to (a) reproduce the form in alternative formats and (b) automatically associate each form field with a column in an existing database (to insert data).Jotform charge a licensing fee if you want to use the builder in your own application (which is not a problem if it's affordable) but I was looking for something more flexible from a developer's angle.
James wrote on 09/03/09 2:15 PM
@Gary,While I love your original Project of the Jquery Form Builder, I've got to admit that for the moment all I'm really looking for is an HTML version of the form to store into a database.
I'm loving it, but do you have a ColdFusion Verion? It's been so long since I did PHP, I've got to re-think how to parse the Data.
Gary F wrote on 09/03/09 2:22 PM
@James, it's not my project. The blog owner, Matthew AKA spiraldev, did it. Perhaps my numerous comments here make it look as if I'm involved!@Matthew, have you given up with this project?
Matt wrote on 09/03/09 5:44 PM
@Gary I have not abandoned this project but could use help.dave evartt wrote on 09/08/09 1:04 PM
I have a jQuery plugin that takes a Coldfusion query and populates a form using the data from the query. It handles radio,checkboxes, text, selects, textarea, etc.It is used to populate a form from an AJAX call to a coldfusion function that returns a serialized query.
spiraldev wrote on 09/08/09 1:09 PM
@dave evarttI would like to see it.
Dave Evartt wrote on 09/09/09 4:52 AM
Here is the plugin, it is 3K uncompressed/*
* formPopulate - jQuery JavaScript plugin v1.0.0
*
* Copyright (c) 2009 Dave Evartt
* Dual licensed under the MIT and GPL licenses.
* http://docs.jquery.com/License
*
* Date: 08 SEP 2009
* formPopulate - populate a form from a ColdFusion query containing
* one row of data.
* Loops through the query, one column at a time.
* If we find an element with the same same (both uppercased)
* we will take the value of the query column and
* put it into the element of the same name.
*
* Correctly handles radio and checkboxes, which are stored in
* arrays in the form, as well as the other elements.
*
* Select only supports single selects at this time.
* ignores undeclared elements (does not generate an error
* if the element does not exist)
*/
(function($){$.fn.formPopulate = function(options) {
var defaults = {
json: ""
};
function setRadioCheckBox(arrayObj, newValue) {
if(!arrayObj)
return;
var arrayLength = arrayObj.length;
if(arrayLength == undefined) {
arrayObj.checked = (arrayObj.value == newValue.toString());
return;
}
for(var i = 0; i < arrayLength; i++) {
arrayObj[i].checked = false;
if(arrayObj[i].value == newValue.toString()) {
arrayObj[i].checked = true;
}
}
}
function PopulateForm(theForm,json){
var targetForm = document.getElementById(theForm);
var columns = json.COLUMNS;// columns from query
var values = json.DATA; // values from query
for (var i = 0; i < columns.length; i++) {
var Column=columns[i];
var value=values[Column][0];
try {
document.getElementById('MSG'+Column).innerHTML='';
//get the object(required to get radio/checkboxe arrays)
var element = targetForm[Column];
//Get the object Type (can't get it from the form above)
var elementType = document.getElementById(Column).type;
switch(elementType)
{
case 'radio':
case 'checkbox':
setRadioCheckBox(element, value);
break;
//everything else is simple
default:
element.value = value;
}//switch
}
catch(err)
{}
}
}//populateForm
// Main loop starts here
var options = $.extend(defaults, options);
var json = options.json;
return this.each(function() {
PopulateForm(this.name,json);
});
};
})(jQuery);
************************************************
// And Here is how you call it.
var json = ColdFusion.JSON.decode(JSON);
//populate using jQuery
$(theForm).formPopulate({json:json});
// And here is how you get the query
<cffunction access="remote" name="getProjectBudgetNumbers" output="no" returnformat="plain" returnType="any" verifyclient="no" securejson="false">
************************************************
<cfquery name = "qry" datasource ="#DSN#">
SELECT whatEver
FROM whereEver
</cfquery>
<cfreturn serializeJSON(qry,true)>
</cffunction>
Assumptions:
use of CFAJAXPROXY to a CFC
elements in 'theForm' have UPPERCASED Ids that match the columns you want to display.
This plugin was my first jQuery plugin and was mostly done as an exercise. It was adapted from some existing JS of mine.
paul wrote on 10/06/09 6:42 AM
Hi, I was wonder if this form builder of yours uses Cold Fusion? or is it purely json and jquery?Dave Evartt wrote on 10/07/09 7:00 AM
Paul,The backend that supplies the JSON query is ColdFusion. The plugin itself is all jQuery. Having said all that, There is no standard in JSON on how a query should look, so ColdFusion supplies the JSON object in a format that as far as I know, is unique. The JSON object consists of two objects, the first (columns) contains the names of the columns contained in the query. The second (data) contains the data for the columns.
What I have done is to loop through the array of columns, get the corresponding data element and stuff that into the element on the page.
If you wanted to use something other than ColdFusion for the backend, there are several ways to handle it;
1. Emulate the ColdFusion format on the backend
2. Emulate the Coldfusion format on the javascript side
3. modify the plugin to use the data format that you need.
Since this plugin was based on working code and was mostly an exercise to learn jQuery, and because there is no standard way to represent a query in JSON, I'm afraid I can't advise which option to take. We are a ColdFusion shop and as such, it fulfills our requirements. I have no idea what other backends (PHP,ASP,JSP, java, Ruby, Python, etc) produce in the way of JSON as, though I've used most of them, I've never done anything using JSON with them.
I'm afraid that if you want to adapt the plugin to some other backend, you'll just have decipher the JSON object and adapt the plugin or the backend to suit your purposes. If you should opt to pursue this, I'll be happy to answer any specific questions to help you out.
Maybe what it should do is have another option: format, which can contain a tag "CF8", for instance, indicating the format of the the incoming JSON object and let the plugin have an internal function to handle the parsing appropriately.
Since this plugin was just tossed out there for the taking, it has no real support. I would certainly entertain the idea of making a generic plugin if there was a demand for such a thing.
paul wrote on 10/20/09 7:50 AM
Hi Dave,Thanks for your reply. I have to try your advice on emulating coldfusion's behavior.
Again, Thanks and more power.
Paul
stop snoring wrote on 11/04/09 10:27 PM
Nice Post I already digged thisChildrens Upholstered Furniture wrote on 12/17/09 8:59 PM
Hi,I want to buy more memory for my notebook.
Chad McCue wrote on 01/06/10 6:29 AM
Do you have a copy of your json.cfm file that your jquery plug in uses?Search Engine wrote on 01/26/10 5:18 AM
Good job! Thank you for the post.You really put some great suggestions on there and were very helpful for people who are newcomers in this sphere. With the help of your site I can broaden my depth of knowledge and experience as much as possible.HVAC Baltimore wrote on 02/02/10 3:06 AM
I loved the way you exlained things. Much better many hereRegards
Anthony
Landscaper Raleigh wrote on 02/02/10 4:03 AM
This is the best post on this topic i have ever read.Regards
Andrea