submitting data from a flash form in coldfusion

Ask a Question related to Coldfusion Flash Integration, Design and Development.

  1. #1

    Default submitting data from a flash form in coldfusion

    :confused;

    I am completely new to using flash forms in coldfusion web applications. I
    created a <cfrom format=flash> type form with a number of text input fields,
    checkboxes and radio buttons. Now I simply want to submit the form to obtain
    the data to put into a MySQL database and to use for various other purposes. I
    have spent a couple of days surfing the net to find out the simpliest way to do
    this, but am completely confused on what to do. The Coldfusion documentation
    makes reference to an ActionScript named submitForm(), but I cannot seem to
    find a clear explanation of how to use this function. I have also seen some
    documentation on using getURL() to pass the form data to a cfm, but not sure
    how to use this. I tried to use the getURL() funciton in the onClick event of a
    button, but did not seem to work. I know nothing about ActionScript, but have
    used JavaScript, PHP and ColdFusion to develop dynamic web pages before. If
    some one could point me in the right direction, or provide a simple example and
    explanation of an easy way to submit data from a Flash form created in
    Dreamweaver 8 and ColdFusion 7 it would be greatly appreciate.

    wallenb Guest

  2. Similar Questions and Discussions

    1. Submitting data from single tab using multiple tab form
      I have a flash form with multiple tabs. When a submit button is pressed, however, I would like only the information from the current tab to go to...
    2. Submitting form
      Can i know whether any1 know hw to submit our form after validating to another form where we can get the input from the first page for .mxml?? And...
    3. Submitting data to database via form
      When I submit data to my Access database, two things happen or rather don't happen. 1) the database is not updated and 2) I get an http 500 error...
    4. mx 7 flash form The form data has expired, Please reloadthis page in your browser.
      When i first go to any flash form on my CFMX 7 server i get the following message. The form data has expired, Please reload this page in your...
    5. Use PDf fill in form in Website and submitting form info.
      I feel like I'm 99% there, but I am missing something. I created the PDF form offline and tested submitting it. It works fine. When I upload and...
  3. #2

    Default Re: submitting data from a flash form in coldfusion

    As far as I've seen, you should be able to submit the format=Flash form in the
    exact same way as a plain old html form. A caveat to this, of course, is that
    this only works with the generic input types; if you are trying to update,
    insert and delete cfgrid items, that is another story.

    But anyway, what I did on mine, just like on all my old html forms, was to put
    both a submit and MM_InsertRecord field on my form. To handle the form
    submission, I simply looked for the state of "MM_InsertRecord", and proceeded
    like normal. Here is a sample of one of mine:



    <cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
    <!---Begin Form Insertion Functionality--->
    <cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "myform">
    <cfquery datasource="#request.dsn#">
    INSERT INTO posts (PostID, PostTitle, PostDate, PostImage, CategoryID,
    UserID, PostImageCaption, PostKeyword1, PostKeyword2, PostKeyword3, PostContent)
    VALUES (
    <cfif IsDefined("FORM.PostID") AND #FORM.PostID# NEQ "">
    '#FORM.PostID#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.PostTitle") AND #FORM.PostTitle# NEQ "">
    '#FORM.PostTitle#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.PostDate") AND #FORM.PostDate# NEQ "">
    '#FORM.PostDate#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.fileNameField") AND #FORM.fileNameField# NEQ "">
    '#FORM.fileNameField#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.CategoryID") AND #FORM.CategoryID# NEQ "">
    #FORM.CategoryID#
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.UserID") AND #FORM.UserID# NEQ "">
    #FORM.UserID#
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.PostImageCaption") AND #FORM.PostImageCaption# NEQ "">
    '#FORM.PostImageCaption#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.PostKeyword1") AND #FORM.PostKeyword1# NEQ "">
    '#FORM.PostKeyword1#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.PostKeyword2") AND #FORM.PostKeyword2# NEQ "">
    '#FORM.PostKeyword2#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.PostKeyword3") AND #FORM.PostKeyword3# NEQ "">
    '#FORM.PostKeyword3#'
    <cfelse>
    NULL
    </cfif>
    ,
    <cfif IsDefined("FORM.PostContent") AND #FORM.PostContent# NEQ "">
    '#FORM.PostContent#'
    <cfelse>
    NULL
    </cfif>
    )
    </cfquery>
    <cflocation url="../feeds/updatefeed.cfm?categoryID=#FORM.CategoryID#"
    addtoken="yes">
    </cfif>
    <!---End Record Insertion FUnctionality--->

    <!---Begin Script for handling File Upload and Display--->
    <cfsavecontent variable="swf"><cfoutput><p><img id="upload" hspace="0"
    vspace="0" src="fileUpload.swf"></p></cfoutput></cfsavecontent>
    <cfsavecontent variable="uploadScript">
    var uploadSwf = textArea.label.upload;
    uploadSwf.upload("upload.cfm");
    uploadBtn.enabled = false;
    browseBtn.enabled = false;
    myform.picture = "";
    </cfsavecontent>
    <cfsavecontent variable="checkVersion">
    var version = getVersion();
    var versionNumber = Number(version.substr(4,1));
    if(versionNumber < 8)
    {
    var msg = '<p>This example requires Flash Player 8 <br><font
    color="#0000ff"><a
    href="http://www.macromedia.com/software/flashplayer/public_beta/">Download it
    from Macromedia</a></font></p>'
    var alertSettings:Object = {title:'Warning', message: msg, width:200,
    headerHeight:27 }
    errorpopup = mx.managers.PopUpManager.createPopUp(this, FormErrorException,
    true, alertSettings);
    errorpopup.centerPopUp(this);
    }
    </cfsavecontent>
    <cfsavecontent variable="browseScript">
    var uploadSwf = textArea.label.upload;
    var panelInfo = panelInfo;
    var output = output;
    var uploadListener = {};
    var progressBar = progressBar;
    var totalWidth = progressBarBackground.width;
    var fileNameField = fileNameField;
    var uploadBtn= uploadBtn;
    var browseBtn= browseBtn;
    var maxSize = 1024 * 300;
    var myform = myform;

    uploadSwf.addListener(uploadListener);
    uploadSwf.browse([{description: "Image Files", extension:
    "*.jpg;*.png;*.gif"}]);


    _global.MathNumberParse= function(n)
    {
    return (n >> 0)+"."+ (Math.round(n*100)%100);
    }
    uploadListener.onSelect = function(selectedFile)
    {
    panelInfo.text = "Name: "+ selectedFile.name + "\n";
    panelInfo.text += "Size: "+selectedFile.size+ " bytes\n";
    panelInfo.text += "Type: "+selectedFile.type+ "\n";
    panelInfo.text += "Creation Date: "+ selectedFile.creationDate+ "\n";
    panelInfo.text += "Modification Date: "+ selectedFile.modificationDate+ "\n";

    if(selectedFile.size < maxSize || maxSize == undefined)
    {
    uploadBtn.enabled = true;
    output.text = "";
    }
    else
    {
    output.text = "The file selected exceeds maximum allowed size";
    uploadBtn.enabled = false;
    }
    fileNameField.text = selectedFile.name;
    }
    uploadListener.onComplete = function()
    {
    output.text = "Upload complete";
    myform.picture = fileNameField.text;
    uploadBtn.enabled = false;
    browseBtn.enabled = true;
    }
    uploadListener.onProgress = function(fileRef, bytesLoaded, bytesTotal)
    {
    progressBar.visible = true;
    var kLoaded = bytesLoaded/1024;
    var kTotal = bytesTotal/1024;
    var loaded = (kLoaded < 1024) ? _global.MathNumberParse(kLoaded) + " KB":
    _global.MathNumberParse(kLoaded/1024) + " MB";
    var total = (kTotal < 1024) ? _global.MathNumberParse(kTotal) + " KB":
    _global.MathNumberParse(kTotal/1024) + " MB";
    var percentage = Math.round(bytesLoaded * 100 / bytesTotal);
    output.text = percentage+ "% uploaded - ";
    output.text += loaded + " of " + total;

    progressBar.width = totalWidth / 100 * percentage;
    }
    uploadListener.onSecurityError = function(fileRef,errorString)
    {
    output.text = "Security Error: "+ errorString;
    uploadBtn.enabled = true;
    browseBtn.enabled = true;
    }
    uploadListener.onIOError = function(fileRef)
    {
    output.text = "IO Error";
    uploadBtn.enabled = true;
    browseBtn.enabled = true;
    }
    uploadListener.onHTTPError = function(fileRef,errorNumber)
    {
    output.text = "HTTP Error number:" + errorNumber;
    uploadBtn.enabled = true;
    browseBtn.enabled = true;
    }
    uploadListener.onCancel = function()
    {
    output.text = "Action cancelled";
    browseBtn.enabled = true;
    }
    </cfsavecontent>
    <cfsavecontent variable="buttonStyle">
    border-thickness:0;
    corner-radius: 0;
    </cfsavecontent>
    <cfsavecontent variable="progressBarStyle">
    border-thickness:0;
    corner-radius: 0;
    fill-colors: #00CCFF, #0075D9;
    theme-color: #00CCFF;
    border-color:#00CCFF;
    color:#ffffff;
    </cfsavecontent>

    <!---ENd Script for File Upload and Display--->

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>
    <head>
    <title>Upload and show: simple case</title>
    <cfquery name="User" datasource="#request.dsn#">
    SELECT *
    FROM Users
    </cfquery>

    <cfquery name="PostCategory" datasource="#request.dsn#">
    SELECT *
    FROM PostCategories
    ORDER BY CategoryName ASC
    </cfquery>
    </head>

    <body>

    <cfform name="myform" height="700" width="700" format="Flash" timeout="0"
    skin="haloblue">
    <cfformgroup type="tabnavigator">
    <cfformgroup type="page" label="Text">
    <cfselect
    name = "UserID"
    multiple="no"
    required = "Yes"
    message = "Select a Username"
    query = "User"
    display ="Username"
    value ="UserID"
    queryPosition="Below" label="Username" width="150">
    <!--- Add an option to select all employees. --->
    <option value = "">---Select Username---</option>
    </cfselect>
    <cfselect
    name = "CategoryID"
    multiple="no"
    required = "Yes"
    message = "Select a Category"
    query = "PostCategory"
    display ="CategoryName"
    value ="CategoryID"
    queryPosition="Below" label="Category" width="150">
    <!--- Add an option to select all employees. --->
    <option value = "">---Select Category---</option>
    </cfselect>
    <cfinput type="text" name="PostTitle" label="Post Title" message="You must
    enter a Post Title." tooltip="Enter Post Title Here" validateat="onBlur"
    required="yes" size="50">

    <cfinput type="datefield" name="PostDate" label="Post Date" message="You must
    enter a valid Post Date." tooltip="Enter Post Date Here" validateat="onBlur"
    required="yes" width="100" mask="yyyy-mm-dd">

    <cftextarea name="PostContent" label="Post Content" tooltip="Enter Post
    Content Here" required="yes" validateat="onBlur" rows="10"
    width="500"></cftextarea>

    </cfformgroup>

    <cfformgroup type="page" label="Image">
    <cfformgroup type="vbox">
    <cfformgroup type="horizontal">
    <cfinput type="text" name="PostImageCaption" tooltip="Add Picture Caption
    Here" label="Picture Caption:" size="20">
    </cfformgroup>
    <cfformitem type="hrule"></cfformitem>
    <cfformgroup type="horizontal">

    <cfinput type="text" name="fileNameField" width="180" disabled="true"
    style="disabledColor:##000000" label="Upload Image:">
    <cftextarea name="textArea" disabled="true" visible="false" width="0"
    bind="{(textArea.html = true) ? '#swf#' : ''}" height="30"></cftextarea>
    <cfinput type="button" name="browseBtn" style="#buttonStyle#"
    onclick="#checkVersion##browseScript#" value="Choose File" />
    <cfinput type="button" name="uploadBtn" disabled="true"
    style="#buttonStyle#" onclick="#uploadScript#" value="Upload File" />
    </cfformgroup>
    <cfformgroup type="vbox" style="verticalGap:0; indicatorGap:0;
    marginLeft:12;" width="400">
    <cfinput type="text" height="1" visible="false"
    name="progressBarBackground">
    <cfinput type="button" height="16" width="0" visible="false"
    name="progressBar" style="#progressBarStyle#"/>
    <cfinput type="text" name="output" disabled="true" style="borderStyle:none;
    disabledColor:##333333;">

    </cfformgroup>

    <cfformitem type="html" height="400" w
    existdissolve Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139