cfif help

Hello
I'm new to CF and need some help with a form. I have three
radio buttons and one is <cfinput type="radio" name="rsvp"
value="Yes, my spouse/partner will also attend"> (Other two are
just Yes and No values with same name="rsvp") and if you select
this one there is a form feild to fill in your spouse/partner's
name (<cfinput type="text" size="15" name="spousepartner">).
I would like it so if that radio button is marked, then it is
required that the user fills in the corresponding text feild,
giving them an error if they do not. Also, when the form is
submitted an email will go out containing the form information, and
I would like there to be a line that displays the Spouse/partner's
name ONLY if that option was checked and a name was supplied.
Example---
RSVP: #form.rsvp#
Spouse/Partner's Name: #form.spousepartner# (Assuming they
did select that option, otherwise just have the RSVP line)
I have no knowledge of how to use the <cfif> tag and
was wondering if anyone could help me out here. Let me know if this
requires furthur clarification (or if I'm rambling and need to shut
up).
Thank you
Jakob

do you have to use radio buttons? cause here is one i found
works but then you will have to impliment the spouce field for
entering their name
<SCRIPT LANGUAGE="JavaScript"><!--
function codename() {
if(document.formname.prim.checked)
document.formname.multi.disabled=true;
else
document.formname.multi.disabled=false;
//-->
function codename1() {
if(document.formname.multi.checked)
document.formname.prim.disabled=true;
else
document.formname.prim.disabled=false;
//-->
function codename2() {
if(document.formname.Etc.checked)
document.formname.Mtc.disabled=true;
document.formname.Tur.disabled=true;
document.formname.wegb.disabled=true;
document.formname.ost.disabled=true;
document.formname.other.disabled=true;
document.formname.Pmtc.disabled=true;
document.formname.Ctel.disabled=true;
document.formname.Cmtc.disabled=true;
document.formname.Cmtt.disabled=true;
document.formname.Supplemental.disabled=true;
else
document.formname.Mtc.disabled=false;
document.formname.Tur.disabled=false;
document.formname.wegb.disabled=false;
document.formname.ost.disabled=false;
document.formname.other.disabled=false;
document.formname.Pmtc.disabled=false;
document.formname.Ctel.disabled=false;
document.formname.Cmtc.disabled=false;
document.formname.Cmtt.disabled=false;
document.formname.Supplemental.disabled=false;
//-->
function codename3() {
if(document.formname.Mtc.checked)
document.formname.Etc.disabled=true;
document.formname.Tur.disabled=true;
document.formname.wegb.disabled=true;
document.formname.ost.disabled=true;
document.formname.other.disabled=true;
document.formname.Pmtc.disabled=true;
document.formname.Ctel.disabled=true;
document.formname.Cmtc.disabled=true;
document.formname.Cmtt.disabled=true;
document.formname.Supplemental.disabled=true;
else
document.formname.Etc.disabled=false;
document.formname.Tur.disabled=false;
document.formname.wegb.disabled=false;
document.formname.ost.disabled=false;
document.formname.other.disabled=false;
document.formname.Pmtc.disabled=false;
document.formname.Ctel.disabled=false;
document.formname.Cmtc.disabled=false;
document.formname.Cmtt.disabled=false;
document.formname.Supplemental.disabled=false;
//-->
</SCRIPT>
<cfform action="../test.cfm" method="" name="formname">
<table class="form" height="300" width="607">
<tr>
<td width="24"> </td>
<td colspan="3"> </td>
<td
colspan="2"><strong>Type</strong></td>
<td width="303"> </td>
</tr>
<tr>
<td><cfinput name="prim" type="checkbox"
onclick="codename()" value="1" /></td>
<td colspan="4">Primary</td>
<td width="20"><cfinput name="multi"
type="checkbox" onclick="codename1()" value="1" /></td>
<td>Multiplier</td>
</tr>
<tr>
<td colspan="7"> </td>
</tr>
<tr>
<td> </td>
<td colspan="3"> </td>
<td
colspan="2"><strong>SubPart</strong></td>
<td> </td>
</tr><!--- make sure that you create the function
for all of them and call it the same name as the onclick --->
<tr>
<td><cfinput name="Etc" type="checkbox"
onclick="codename2()" value="1" /></td>
<td colspan="4">B - E T C</td>
<td><cfinput name="Mtc" type="checkbox"
onclick="codename3()" value="1" /></td>
<td>C - MTC</td>
</tr>
<tr>
<td><cfinput name="Tur" type="checkbox"
onclick="codename4()" value="1" /></td>
<td colspan="4">D - Tur</td>
<td><cfinput name="wegb" type="checkbox"
onclick="codename5()" value="1" /></td>
<td>E - WEPG</td>
</tr>
<tr>
<td><cfinput name="ost" type="checkbox"
onclick="codename6()" value="1" /></td>
<td colspan="4">F - Ost</td>
<td><cfinput name="other" type="checkbox"
onclick="codename7()" value="1" /></td>
<td>G - Other</td>
</tr>
<tr>
</tr>
<tr><td height="24" colspan="8"></a>
<!--- need to make searches for all forms because of different
attributes on every form --->
</tr></table><input type="submit"
value="submit" />
</cfform>

Similar Messages

  • Need help with cfif, cfelseif

    I am trying to display a slideshow within an include file depending upon what category selection someone makes within a CF page.
    I have tried the following using both URL= and template= with no luck. Any help would be appreciated.
    <cfif TxtProductMenuSelected eq "NewProducts">
    <cfinclude URL="IncludeFiles/ContractHome-include.cfm">
    <cfelseif TxtProductMenuSelected eq "Chandeliers">
    <cfinclude URL="IncludeFiles/ProdHome-include.cfm">
    <cfelseif TxtProductMenuSelected eq "LargeFixtures">
    <cfinclude URL="IncludeFiles/test-include.cfm">
    <cfelse>
    I don't have a clue! Seriously.
    </cfif>

    btvbillb wrote:
    I have posted all the code below. Basically, it's a page that displays thumbnail images and a Flash slideshow depending upon which category is selected. I have commented out the Flash sildeshow and created include files for the code to a javascript slideshow instead. I was using TxtProductMenuSelected as the criteria for displaying the appropriate include file. Hope this all makes sense.
    http://www.cylonweb.com/test/test.cfm
    Your code is behaving as expected. The last line to update the value of the variable TxtProductMenuSelected before the if-else block is:
    <cfset TxtProductMenuSelected = "">
    That is why the comparisons with "NewProducts", etc. return false.

  • I ask to help on pagination

    I ask to help on pagination
    All greetings! For me a question on pagination
    Has made pagination for the directory of articles on a site, but at addition of new articles in a database, having divided into pages proceeds in a format
    BACK 1 2 3 4 5 6 7 8 NEXT
    So can proceed indefinitely (to 100-200 pages etc.).
    I wish to make, that pagination was in such format:
    BACK 1 2 3 4 5 6 7 8 9 10... NEXT
    That is, that pages were displayed to 10, and the others were not displayed, and began to be displayed, when the user has reached 10 pages, for example:
    BACK... 11 12 13 14 15 16 17 18 19 20 NEXT
    CODE:
    <cfquery name="getArticle" datasource="Article" result="resultInfo">
    SELECT Articles.Id, Articles.title, Articles.anonce, Articles.disc, Articles.add_date, Articles.image, Articles.tag
    FROM Articles
    </cfquery>
    <!--- set how many records you want to display per page --->
    <cfset Result_Per_Page="1">
    <!--- get the total record count from q_fetch query --->
    <cfset Total_Records="#getArticle.recordcount#">
    <!--- set the default value for the offset record set number --->
    <cfparam name="URL.offset" default="0">
    <!--- the limit result set(i.e., end row) --->
    <cfset limit=URL.offset+Result_Per_Page>
    <!--- page results start from? --->
    <cfset start_result=URL.offset+1>
    <!--- make sure that the initial start row is starting from 1 --->
    <cfset URL.offset=URL.offset+1>
    <!--- if the record is their more than one page so show the navigation bar --->
    <cfif Total_Records GT Result_Per_Page>
    <br>
    <!--- Create Previous Link --->
    <cfif URL.offset GT Result_Per_Page>
    <!--- Previous Link Offset --->
    <cfset prev_link=URL.offset-Result_Per_Page-1>
    <cfoutput><b class="numpage_link"><a href="#cgi.script_name#?offset=#prev_link#">BACK</a></b></cfoutput>
    </cfif>
    <!--- Find out how many pages are there for display  --->
    <cfset Total_Pages=ceiling(Total_Records/Result_Per_Page)>
    <!--- now loop it for navigation page numbers --->
    <cfloop index="i" from="1" to="#Total_Pages#">
    <cfset j=i-1>
    <!--- create offset value for page numbers --->
    <cfset offsetvalue=j*Result_Per_Page>
    <!--- deactivate the link if the page number is current page --->
    <cfif offset_value EQ URL.offset-1 >
    <cfoutput><b class="numpage">#i#</b></cfoutput>
    <cfelse>
    <cfoutput><b class="numpage_link"><a href="#cgi.script_name#?offset=#offset_value#">#i#</a></b></cfoutput>
    </cfif>
    </cfloop>
    <!--- create Next Link --->
    <cfif limit LT Total_Records>
    <!--- Next Link Offset --->
    <cfset next_link=URL.offset+Result_Per_Page-1>
    <cfoutput><b class="numpage_link"><a href="#cgi.script_name#?offset=#next_link#">NEXT</a></b></cfoutput>
    </cfif>
    </cfif>
    <!--- display the result on the screen --->
    <cfloop query="getArticle" startrow="#URL.offset#" endrow="#limit#">
    <cfoutput>
    <div class="center_item_line">
    <h4>#DateFormat(Now())# <p>#getArticle.tag# </p></h4>
    <div class=center_item_img><a href="article.cfm?ID=#getArticle.Id#"><img src="../images/#getArticle.image#" width="180" height="133" alt="Новости зарубежной недвижимости"></a></div>
    <h4><a href="article.cfm?ID=#getArticle.Id#">#getArticle.title#</a></h4>
    <p>#getArticle.anonce# </p>
    <div style='clear:both;'></div>
    <br/>
    <div class="line"></div>
    </div>
    </cfoutput> <br>
    </cfloop>
    </body>

    You might want to take a look at the PaginationCFC project at RIAForge.com:
    http://paginationcfc.riaforge.org/
    It looks like a very useful pagination library that could help you manage your large data set output.

  • Please Help me in solving this issue. i am a newbie to coldfusion

    i want to use a single home page where i will show a form (which is in another file) to user to upload a file,after uploading (action file result) i want to show result of upload also on the same page.
    these are my three files:
    1. index.cfm
    <!-- start -->
    <html>
    <head>
    <title>HomePage</title>
    <cfajaximport tags="CFFORM">
    </head>
    <body>
    <cfdiv id="Main" style="width:1000px; height:600px" >
            <cfdiv id="Options" style=" width:100%;height:20%" >
                Welcome Admin, <a href="javascript:ColdFusion.navigate('FileUpload.cfm','Content')" class="settings">Update  </a><a href="#" class="logout">Logout</a>
            </cfdiv>
            <cfdiv id="Content" style=" width:100%;height:80%">
    <h2>Here Goes Form and FileUploading</h2>
            </cfdiv>
    </cfdiv>
    </body>
    </html>
    <!--  -->
    2.FileUpload.cfm
    <!-- start -->
    <html>
        <head>
            <title>
                Upload A File
            </title>
        </head>
        <body >       
    <cflayout type="vbox" name="layout1">
    <cflayoutarea>
        <cfform  enctype="multipart/form-data"  action="FileReceiver.cfm" >
                            File To Upload:
                            <cfinput type="file" name="Filename" size="50" >
                 <br/>       
                            <cfinput type="submit" name="UploadFile" value="UPLOAD THIS FILE">
                    <br/>
            </cfform>
    </cflayoutarea>
    <cflayoutarea>       
        <table border="1" >
                <tr>
                <th >
                    Directory Information
                </th>
                </tr>
                <tr>
                    <td>
                    <cfoutput >
                        CurrectDirectory Path: #getdirectoryFromPath(expandPath("index.cfm"))#
                    </cfoutput>
                    </td>
                </tr>
            </table>
    </cflayoutarea>
    </cflayout>
        </body>
    </html>
    <!-- -->
    3.FileReceiver.cfm
    <!---start-->
    <cfif isdefined('UploadFile')  >
    <cfoutput >
    <cffile nameconflict="makeunique"
    action="upload"
    filefield="Form.Filename"
    destination="#getdirectoryFromPath(expandPath("index.cfm"))#" > <!--- or destination="c:\Upload\"--->
            File upload was successful!
    </cfoutput>
    </cfif>
    <!-- -->
    when i click on "update link" index page shows the FileUpload.cfm page in one of its container but while uploading file
    i always get ERROR MESSAGE:
    Error retrieving markup for element cf_layoutarea736558924094373 : Invalid content type: application/x-www-form-urlencoded; charset=UTF-8. [Enable debugging by adding 'cfdebug' to your URL parameters to see more information]
    Kindly Help me doing it right...i am unable to figure out problem ...

    Ah, I found the cause of the issue: Coldfusion stores the properties of user-interface tags like cfdiv and cflayoutarea in the form scope. That is what is destroying your upload form. To see it, run the following test code:
    <cfdump var="#form#">
    <cflayout type="vbox" name="layout1">
    <cflayoutarea name="myLayoutArea123">
    <cfform >
    <cfinput type="submit" name="submit" value="Test by posting form to same page.">
    </cfform>
    </cflayoutarea>
    </cflayout>
    Now, the search for a possible solution.

  • Need help with an innerjoin issue

    Hello;
    I am writting a small app for my web site and have run into
    an issue with an innerjoin. Let me explain what the function is for
    this so maybe you can understand what I am doing.
    There are 2 pages to this. Page 1, is a category selection
    page. It loads all the categories on the page with a link that
    passes a category ID to page 2. Page 2, then allows you to view all
    the projects that are associated to the specific category. There is
    a numbered navigation on this page, kind of like google, 1 2 3 4
    More> Next>
    Now what I am trying to do it create a select function that
    allows you to choose another category to look through on page 2 so
    you don't have to go back to page 1 and select another category
    there.
    Right now, I have the innerjoin working well with page 1
    going to page 2 and the numbered nav, it is doing what it is
    supposed to. BUT the select function is working off the where
    clause and not working independantly from what the numbered nav and
    body is supposed to be doing. There is also a spot I added to this
    page that kind of works like the select function, it puts the name
    of the category your viewing on the page.
    What is happening with the select function and this name
    function is lets say there are 5 project records tied to the
    category you selected, then the select function gets 5 names of the
    same category in it and so does the category name function.
    (Follow this?)
    Let me post the code for page 1 and page 2. also will add
    what the tables are in the db.
    DB tables:
    Table1: Categories
    Name (this is the actual category name), MYFile(the file that
    give an image of the category), Description(a description of this
    category), CategoryID (this is added to the projects table for each
    project that is connected to each category)
    Table 2: Projects
    ProjectID (this is the ID of the projects), Name (this is the
    name of the project) Body (thi sis the description and picture of
    the project), CategoryID (this is the id of what category the
    project falls under, also assigned to tproject from the categories
    table)
    There is a lot of code that goes in this, so I am going to
    post the code that is pertinent to this question, 90% of it is
    working at this time, just not the select function and category
    name on page 2.
    Page1 Code:
    <CFQUERY name="GetRecord"
    datasource="#APPLICATION.dataSource#">
    select Name, MYFile, Description, CategoryID
    FROM Categories
    </CFQUERY>
    <head>
    </head>
    <body>
    <cfloop query="GetRecord" startRow="#URL.startRow#"
    endRow="#endRow#"><cfoutput>
    <img src="../img/cat/#MYFile#" width="50" height="50">
    <a
    href="portfolio-detail.cfm?CategoryID=#CategoryID#">#Name#</a>
    #Description#
    </cfoutput></cfloop>
    <!--- there is a numbered nav on this page, it works nice
    so I didn't add the code, that is why I am using a cfloop --->
    Page2 code:
    <CFQUERY name="getProjects"
    datasource="#APPLICATION.dataSource#">
    SELECT Projects.ProjectID, Projects.Name, Projects.Body,
    Projects.CategoryID,
    Categories.CategoryID AS catID, Categories.Name AS cat_name
    FROM Projects
    INNER JOIN Categories
    ON Categories.CategoryID = Projects.CategoryID
    WHERE Projects.CategoryID = #categoryID#
    ORDER BY ProjectID
    </CFQUERY>
    <cfif getProjects.recordCount is 0>
    No projects in this category.
    <cfabort>
    </cfif>
    <head>
    <!--- this script is for the select function so when you
    make a selection, it goes to the next category without having to
    hit a submit button --->
    <script language="Javascript">
    function changeRecord(){
    document.category.submit();
    </script>
    </head>
    <body>
    <!--- here are the Category name and select functions that
    aren't working properly yet --->
    <cfoutput
    query="getProjects">#cat_name#</cfoutput>
    <form Name="category" method="post"
    Action="portfolio-detail.cfm?CategoryID=true">
    <select name="CategoryID" size="1"
    onChange="category.submit();">
    <option value=""> --Select a Category--
    </option>
    <CFOUTPUT query= "getProjects">
    <option value="#CategoryID#">#cat_name#</option>
    </CFOUTPUT>
    </select>
    </form>
    <!--- this part is working properly, it also has a
    numbered nav, like google that is working properly at this point
    --->
    <cfoutput query="GetProjects" startRow="#startRow#"
    maxRows="#maxRows#">
    #Name#
    #Body#
    </cfoutput>
    <!--- next is the cfmodule for the nav, the nav is a lot
    of code, a whole page on it's own so I am not posting it --->
    <cfmodule
    template="../CFdocs/PageNav.cfm"
    totalItems="#numRows#"
    numPerPage="#maxRows#"
    startRow="#startRow#"
    url="#cgi.script_name#?categoryID=#categoryID#&startRow=#startRow#">
    The main part that is not working properly is the select, and
    category name. How to I get those to work independantly from my
    where clause? (I need the where clause for the numbered nav and
    cycling through the projects tied to the category you called up
    from page 1.
    Can someone help me tweek my code from this point? I am
    stumped, I looked at the cf docs and I can't find a solution. I am
    using CF 8.
    Any help would be appreciated. Thank you!
    CFmonger

    I fixed a lot of this since I posted it this morning. Now all
    that isn't working properly is the select, it isn't passing the
    proper variable to make the query work.
    This is what I have now:
    Page 2:
    <CFQUERY name="getProjects"
    datasource="#APPLICATION.dataSource#">
    SELECT Projects.ProjectID, Projects.Name, Projects.Body,
    Projects.CategoryID,
    Categories.CategoryID AS catID, Categories.Name AS cat_name
    FROM Projects
    INNER JOIN Categories
    ON Categories.CategoryID = Projects.CategoryID
    WHERE Projects.CategoryID = #categoryID#
    ORDER BY ProjectID
    </CFQUERY>
    <!--- I will add the <cfqueryparam> in a bit --->
    <cfif getProjects.recordCount is 0>
    No projects in this category.
    <cfabort>
    </cfif>
    <!--- This query populates the select nav --->
    <CFQUERY name="cata"
    datasource="#APPLICATION.dataSource#">
    select Name, MYFile, Description, CategoryID
    FROM Categories
    </CFQUERY>
    <head>
    <script language="Javascript">
    function changeRecord(){
    document.category.submit();
    </script>
    </head>
    <body>
    <!--- this output works well now, gives me what I need and
    changes when you select a category from page 1 --->
    <cfoutput query="getProjects"
    maxrows="1">#cat_name#</cfoutput>
    <!-- the select isn't passing the CategoryID properly, it
    is now throwing an error --->
    <form Name="category" method="post"
    Action="portfolio-detail.cfm?CategoryID=#CategoryID#">
    <select name="CategoryID" size="1"
    onChange="category.submit();">
    <option value=""> --Select a Category--
    </option>
    <CFOUTPUT query= "cata">
    <option value="#CategoryID#">#Name#</option>
    </CFOUTPUT>
    </select>
    </form>
    <!-- the rest of the code goes after this, it ias all
    working --->
    The error I get when using the select is this:
    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC
    Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error
    (missing operator) in query expression 'Projects.CategoryID ='.
    The error occurred in C:\Websites\folio\portfolio-detail.cfm:
    line 12
    10 : INNER JOIN Categories
    11 : ON Categories.CategoryID = Projects.CategoryID
    12 : WHERE Projects.CategoryID = #categoryID#
    13 : ORDER BY ProjectID
    14 : </CFQUERY>
    I also tried doing it this way:
    <form Name="category" method="post"
    Action="portfolio-detail.cfm?CategoryID=true"
    This way didn't work at all, it only made the numbered nav on
    the page cycle through all the projects in all the categories.
    What do I need to change to pass the proper variable from the
    select nav to the innerjoin query and my where statement?

  • Help needed for dynamic update form

    I could really use some advice - I've been asked to build a time tracking application (basically a timesheet) and I have a fair bit done but the part I am really struggling with is the best way to accommodate some of the specifications. I am NOT a programmer (I have some coldfusion experience but nothing really advanced) so I have not managed to sucessfully integrate the various methods I've found on the web so far. The database is created and so are all the queries, and I have also written a cfc to handle the drop-down menu logic needed but I don't really know how to integrate it with the form.
    Our production server has ColdFusion MX7 so all the great functionality in the CF8 examples I can't use.
    The issue is the user should ideally be able to add/edit/delete multiple rows at once- I like CFGRID, and the HTML version seems best. The main issue with the Flash version is the scrolling to get to the insert/delete buttons- I couldn't see how to get rid of that. A separate add and edit form could be ok depending on how easy it is to use.
    One problem I have is that I can't work out how to have default values with the grid (the userID which is a session variable, and the date which is constantly changing- there is a cfcalendar for the user to change date).
    The biggest hurdle is the related select drop-downs I need- it's not quite as simple as the city,state,postcode examples. For the first drop down the pick an option- and for only 2 of those options there is a second drop-down. Anything else and it stops there. For the second drop-down, there are 2 options, and depending on which one of these they pick the 3rd drop-down pulls a query from one or another table in the database (2 entirely different things). The three  options have different database tables. The main timesheet table just stores the id number from those tables (so I also need to display the names on the drop-down from the options tables not the number).
    I played with simple and complicated javascript and coldfusion solutions as well, but because it's a form to update records and also because of the above specs I just couldn't get anything to work right. I tried binding with the cfc and nothing would bind, plus I don't know how to make all happen without a page reload.
    Does anyone have any advice for the best approach to this? As I mentioned I've got tables, queries and even a cfc but I'm not too clear on how to put it all together properly within the constraints of MX7.
    PS I also can't post a lot of code because of where I work- I know that's not helpful but am looking for the best approach to this, then I can work on the details. Right now I am jumping from solution to solution and not getting anywhere.

    Well, a lot of code has come and gone because I couldn't make it work, where I'm currently at is:
    <cfform name="updateform" id="updateform" action="#CurrentPage#?#CGI.QUERY_STRING#">
      <cfgrid name="MainData" height="400" insertbutton="add" deletebutton="remove" query="getMainData" insert="yes" delete="yes" rowheight="20"  selectmode="edit" format="html">
      <cfgridcolumn name="id" display="no">
    <cfgridcolumn name="userID" display="no">
    <cfgridcolumn name="entrydate" display="no">
    <cfgridcolumn name="activityID" >
    <cfgridcolumn name="typeID">
    <cfgridcolumn name="projectID" values="#ValueList(getProjects.id)#" valuesdisplay="#ValueList(getProjects.name)#">
    <cfgridcolumn name="time" width="10">
    <cfgridcolumn name="comment" width="150">
    </cfgrid>
    <cfinput type="hidden" name="entrydate" value="#Session.username#">
    <cfinput type="hidden" name="entrydate" value="#editdate#">
    <cfinput name="update" type="Submit" value="Update">
    </cfform>
    ** for some reason getProjects.name doesn't work and causes an error. I haven't worked out how to get the default inputs for the date and user ID to work either. I also tried binding and a flash form somewhere along the way.
    ** the CFC is below, #ds# didn't work and I had to put in the actual DSN name, not sure why, but anyway this is the logic of the thing. Ideally I would like to use this logic with the cfgrid, but I'm not sure if that is possible? It seems like it would be the most user friendly approach.
    The CFC so far is:
    <cfcomponent>
       <cffunction name="getActivities" access="remote" returnType="query">
            <cfquery name="getActivities" datasource="#ds#">
    SELECT * FROM timesheet_activities
    </cfquery>
            <cfreturn getActivities>
        </cffunction>
        <cffunction name="getTypes" access="remote" returnType="query">
        <cfargument name="Activity" type="any" required="true">
        <cfif ARGUMENTS.Activity EQ "">
            <cfset getType = "">
        <cfelse>
            <cfquery name="getTypes" datasource="#ds#">
            SELECT * FROM timesheet_type
            </cfquery>
        </cfif>
        <cfreturn getTypes>
        </cffunction>
        <cffunction name="GetProjects" access="remote" returnType="query">
        <cfargument name="Activity" type="any" required="true">
        <cfargument name="Type" type="any" required="true">
        <cfif ARGUMENTS.Activity EQ "" OR ARGUMENTS.Type EQ "">
            <cfset LstProjects = "">
        <cfelseif ARGUMENTS.Activity EQ "1" OR "3">
        <cfquery name="getProjects" datasource="#ds#">
    SELECT id,name FROM projectsa
    WHERE completed = 'false'
    </cfquery>
    <cfelse>
    <cfquery name="getEProjects" datasource="#dse#">
    SELECT id,name FROM projectsb
    WHERE statusID = '6'
    </cfquery>
        </cfif>
        <cfreturn getProjects>
        </cffunction>
    </cfcomponent>
    Any attempts to actually use the cfc didn't work. I tried to use it with a normal html update form and got the message- failed to bind, Activity didn't exist. I also tried to bind it to a flash grid. The argument for Activity needs to come from the drop-down Activity type selected. Maybe I'm missing something.
    ETA:
    just moved everything to the live MX7 server (because my dev server is Coldfusion8) and I get the following:
    Attribute validation error for tag CFGRID. The tag does not allow the attribute(s) BINDONLOAD,BIND.
    Does this mean I definitely can't use the CFC with the cfgrid on MX7? Or is there a way to do it?
    Any advice would be greatly appreciated.

  • Problem with Multi File upload example, help needed

    I got the code from the following location.....
    http://www.adobe.com/devnet/coldfusion/articles/multifile_upload.html
    And I've got it to work to some degree except I cant get the file transfer to work when pressing, Upload.   Below is what my debugger outputs.  Any thoughts on how to fix this or even what it means?
    At the very bottom of this message is the upload.cfm code.......
    Thanks in advance for the help
    <html>
    <head>
      <title>Products - Error</title>
    </head>
    <body>
    <h2>Sorry</h2>
    <p>An error occurred when you requested this page.
    Please email the Webmaster to report this error.
    We will work to correct the problem and apologize
    for the inconvenience.</p>
    <table border=1>
    <tr><td><b>Error Information</b> <br>
      Date and time: 12/07/09 22:25:51 <br>
      Page:  <br>
      Remote Address: 67.170.79.241 <br>
      HTTP Referer: <br>
      Details: ColdFusion cannot determine how to process the tag &lt;CFDOCUMENT&gt;. The tag name may be misspelled.<p>If you are using tags whose names begin with CF but are not ColdFusion tags you should contact Allaire Support. <p>The error occurred while processing an element with a general identifier of (CFDOCUMENT), occupying document position (41:4) to (41:70).<p>The specific sequence of files included or processed is:<code><br><strong>D:\hshome\edejham7\edeweb.com\MultiFileUpload\upload.cfm      </strong></code><br>
      <br>
    </td></tr></table>
    </body>
    </html>
    <!---
    Flex Multi-File Upload Server Side File Handler
    This file is where the upload action from the Flex Multi-File Upload UI points.
    This is the handler the server side half of the upload process.
    --->
    <cftry>
    <!---
    Because flash uploads all files with a binary mime type ("application/ocet-stream") we cannot set cffile to accept specfic mime types.
    The workaround is to check the file type after it arrives on the server and if it is non desireable delete it.
    --->
        <cffile action="upload"
                filefield="filedata"
                destination="#ExpandPath('\')#MultiFileUpload\uploadedfiles\"
                nameconflict="makeunique"
                accept="application/octet-stream"/>
            <!--- Begin checking the file extension of uploaded files --->
            <cfset acceptedFileExtensions = "jpg,jpeg,gif,png,pdf,flv,txt,doc,rtf"/>
            <cfset filecheck = listFindNoCase(acceptedFileExtensions,File.ServerFileExt)/>
    <!---
    If the variable filecheck equals false delete the uploaded file immediatley as it does not match the desired file types
    --->
            <cfif filecheck eq false>
                <cffile action="delete" file="#ExpandPath('\')#MultiFileUpload\uploadedfiles\#File.ServerFile#"/>
            </cfif>
    <!---
    Should any error occur output a pdf with all the details.
    It is difficult to debug an error from this file because no debug information is
    diplayed on page as its called from within the Flash UI.  If your files are not uploading check
    to see if an errordebug.pdf has been generated.
    --->
            <cfcatch type="any">
                <cfdocument format="PDF" overwrite="yes" filename="errordebug.pdf">
                    <cfdump var="#cfcatch#"/>
                </cfdocument>
            </cfcatch>
    </cftry>

    Just 2 things in my test:
    1) I use no accept attribute. Coldfusion is then free to upload any extenstion.
    Restricting the type to application/octet-stream may generate errors. Also, it is unnecessary, because we perform a type check anyway.
    2) I have used #ExpandPath('.')#\ in place of #ExpandPath('\')#
    <cfif isdefined("form.filedata")>
    <cftry>
    <cffile action="upload"
                filefield="filedata"
                destination="#expandPath('.')#\MultiFileUpload\uploadedfiles\"
                nameconflict="makeunique">
            <!--- Begin checking the file extension of uploaded files --->
            <cfset acceptedFileExtensions = "jpg,jpeg,gif,png,pdf,flv,txt,doc,rtf"/>
            <cfset filecheck = listFindNoCase(acceptedFileExtensions,File.ServerFileExt)/>
    <!---
    If the variable filecheck equals false delete the uploaded file immediatley as it does not match the desired file types
    --->
            <cfif filecheck eq false>
                <cffile action="delete" file="#ExpandPath('.')#\MultiFileUpload\uploadedfiles\#File.ServerFile#"/>
                <cfoutput>Uploaded file deleted -- unacceptable extension (#ucase(File.ServerFileExt)#)</cfoutput>.<br>
            </cfif>
    Upload process done!
            <cfcatch type="any">
                There was an error!
                <cfdocument format="PDF" overwrite="yes" filename="errordebug.pdf">
                    <cfdump var="#cfcatch#"/>
                </cfdocument>
            </cfcatch>
    </cftry>
    <cfelse>
    <form method="post" action=<cfoutput>#cgi.script_name#</cfoutput>
            name="uploadForm" enctype="multipart/form-data">
            <input name="filedata" type="file">
            <br>
            <input name="submit" type="submit" value="Upload File">
        </form>
    </cfif>

  • Cfmail not working. Please help!

    I am trying to get this to send an email each time a file is
    uploaded. All the fields in the form are updating the database
    correctly but the email is never sent and no error message is
    generated. Any ideas....please help!!!
    <cfif IsDefined("FORM.ID")>
    <cfupdate datasource="xxxxxxx" tablename="FTPCatalog">
    <cfelse>
    <cfinsert datasource="xxxxxxx" tablename="FTPCatalog">
    <cfmail to = "#SendTo#"
    from = "#EmailAddress#"
    subject = "FTP file upload notification!"
    server = "mail.server.net" >
    A file has been uploaded to the server.
    </cfmail>
    </cfif>

    you do realise that your code as it is in your original post
    will only
    send email when a NEW RECORD is INSERTED into the db? no
    email will be
    sent on UPDATE of db because how your cfif/cfelse is
    constructed.
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com

  • Help!  Form is not submitting or doing anything! Any ideas?

    I inherited this web application and have zero CF experience and any help is greatly appreciated!  So, the "Forgot Password" form isn't working at all.  The email is sent properly from the referring page and when you click the link it brings up the page right, however, when you fill out the form with "email address" and "username" and hit submit, it does nothing.  I'm not even getting an error.
    Is there something I'm missing in the code that is wrong?  I'll post the entire code and what the URL looks like when arriving at this page.  It is still in my dev environment.
    Thanks in advance for ANY help!  I'm really lost and confused.
    http://<server>/~mld/ForgotPassword/index.cfm?plw=359&qke=995708
    <!---
    Project: MLD Registry
    Page Name: index.cfm
    Page Purpose: Home page for Forgot Password pages
    Programmer: Eric Savage
    --->
    <html>
    <head>
              <title>Forgot Password</title>
              <link rel="stylesheet" type="text/css" media="screen" href="../StyleSheet_Display.css" />
              <link rel="stylesheet" type="text/css" media="print" href="../StyleSheet_Print.css" />
    </head>
    <body>
    <cfsilent>
    <cfparam name="plw" default=""><!--- Registry_ID --->
    <cfparam name="qke" default=""><!--- Acct_num_temp --->
    <cfparam name="Email" default="">
    <cfparam name="UserName" default=""><!--- User Name --->
    <cfparam name="CheckEntries" default=""><!--- Check submissions for errors --->
    <cfparam name="Error" default="0">
    <cfparam name="ErrorMessage_Email" default="">
    <cfparam name="ErrorMessage_UserName" default="">
    <cfparam name="ksr" default=""><!--- Forgot password: email/new password sent --->
    <cfparam name="uca" default="">
    <cfif Len(CheckEntries) and Len(UserName) and Len(Email) and Len(plw) and Len(qke)>
              <cftry>
        <cfquery name="CheckIfValidUser" datasource="#Datasource#">
            SELECT                    rid,rid_name,r_email,registry_id,acct_num_temp,r_website_type
            FROM                    registry
            WHERE                    rid_name= <cfqueryparam value="#UserName#" cfsqltype="CF_SQL_VARCHAR"> and r_email= <cfqueryparam value="#Email#" cfsqltype="CF_SQL_VARCHAR"> and registry_id= #plw# and acct_num_temp= #qke#
        </cfquery>
        <cfcatch type="Any">
                        <cfinclude template="../includefiles/inc_EmailWebsiteManager.cfm">
                  <cflocation url="ErrorMessage.cfm" addtoken="No">
            <cfabort>
        </cfcatch>
              </cftry>
              <cfif not CheckIfValidUser.RecordCount>
                        <cftry>
                        <cfquery name="UserLog" datasource="#Datasource#">
                                  INSERT INTO userlog(http_user_agent,todaysdate,ip_address,user_name,comments)
                                  VALUES ('#CGI.http_user_agent#',#CreateODBCDateTime(Now())#,'#remote_addr#','#Email#','ForgotPas sword/index.cfm: failed attempt')
                        </cfquery>
                        <cfcatch type="Any">
                                  <cfinclude template="../includefiles/inc_EmailWebsiteManager.cfm">
                        </cfcatch>
                        </cftry>
              </cfif>
              <cfif CheckIfValidUser.RecordCount>
                        <cfinclude template="../includefiles/inc_Password_CreateRandom.cfm"><!--- Creates random password in variable called RandomlyCreated_Password --->
            <cfset Password_To_Check= RandomlyCreated_Password><!--- Pass value of new password to include file --->
                        <cfinclude template="../includefiles/inc_Password_CheckFormat.cfm"><!--- Check password complies with  --->
                        <cfif Len(ErrorMessage_Password_To_Check)>
                      <cfset ErrorMessage= "(" & #CheckIfValidUser.rid# & ") [auto password gen] " &  ErrorMessage_Password_To_Check>
                <cfinclude template="../includefiles/inc_EmailWebsiteManager.cfm">
                <cflocation url="ErrorMessage.cfm" addtoken="No">
                <cfabort>
                        </cfif>
                        <cfif not Len(ErrorMessage_Password_To_Check)>
                <cftry>
                <cfquery name="UpdatePassword" datasource="#Datasource#">
                    UPDATE                    registry
                    SET                              rid_pass= Password('#RandomlyCreated_Password#')
                    WHERE                    rid_name= <cfqueryparam value="#UserName#" cfsqltype="CF_SQL_VARCHAR"> and r_email= <cfqueryparam value="#Email#" cfsqltype="CF_SQL_VARCHAR"> and registry_id= #plw# and acct_num_temp= #qke#
                </cfquery>
                <cfcatch type="Any">
                    <cfinclude template="../includefiles/inc_EmailWebsiteManager.cfm">
                    <cflocation url="ErrorMessage.cfm" addtoken="No">
                    <cfabort>
                </cfcatch>
                </cftry>
                <cftry>
                <cfquery name="UserLog" datasource="#Datasource#">
                    INSERT INTO userlog(http_user_agent,todaysdate,ip_address,user,comments)
                    VALUES ('#CGI.http_user_agent#',#CreateODBCDateTime(Now())#,'#remote_addr#','#CheckIfValidUser.r id#','ForgotPassword/index.cfm: new password added')
                </cfquery>
                <cfcatch type="Any">
                    <cfinclude template="../includefiles/inc_EmailWebsiteManager.cfm">
                </cfcatch>
                </cftry>
                <cfparam name="Subject" default="(Secure) NDRD Clinical Questionnaire">
                <cfif CheckIfValidUser.r_website_type is "MLD"><cfset Subject= "(Secure) MLD Registry"></cfif>
                <cfif CheckIfValidUser.r_website_type is "NFRD"><cfset Subject= "(Secure) NFRD Registry for Rare Genetic Disorders"></cfif>
                <cftry>
                <cfmail
                    to="#Email#"
                    subject="#Subject#"
                    from="#CONTACT.EMAIL_NURSE#"
                    server="<SMTP SERVER>"
                    type="html">
                    <p>Here is the new password you requested: #RandomlyCreated_Password#.</p>
                </cfmail>
                <cfcatch type="Any">
                    <cfinclude template="../includefiles/inc_EmailWebsiteManager.cfm">
                    <cflocation url="ErrorMessage.cfm" addtoken="No">
                    <cfabort>
                </cfcatch>
                </cftry>
                <cfparam name="WebsiteType" default="">
                <cfif CheckIfValidUser.r_website_type is "Clinic"><cfset WebsiteType= "01345"></cfif>
                <cfif CheckIfValidUser.r_website_type is "MLD"><cfset WebsiteType= "04385"></cfif>
                <cfif CheckIfValidUser.r_website_type is "NFRD"><cfset WebsiteType= "03475"></cfif>
                <cflocation url="index.cfm?ksr=30471&dfa=84836&uca=#WebsiteType#" addtoken="No">
            </cfif>
              </cfif>
    </cfif>
    </cfsilent>
    <cfinclude template="inc_PageTitle.cfm"><!--- Page title --->
    <div id="Container">
              <cfinclude template="inc_NavBar.cfm">
              <div id="Content">
                        <div id="minheight">
                                  <cfoutput>
                                  <cfif not Len(ksr)>
                                            <div style="padding: .5em 0 .75em 0; border-style: solid; border-width: 0 0 1px 0;">
                        Please enter your email address and user name.
                                            </div>
                                            <cfform action="index.cfm" method="POST">
                                                      <p>
                                                      <span class="ResponseLabel_10"><label for="Email">Email Address</label></span>
                                                      <cfinput type="Text" name="Email" id="Email" value="#Email#" message="Please enter an email address" required="Yes" size="30" maxlength="40">
                                                      </p>
                                                      <p>
                                                      <span class="ResponseLabel_10">User Name</span>
                                                      <cfinput type="Text" name="UserName" id="UserName" value="#UserName#" message="Please enter a User Name" required="Yes" size="12" maxlength="50">
                                                      </p>
                                                      <p><input type="submit" value="Submit"></p>
                                                      <input type="hidden" name="CheckEntries" value="Check">
                        <cfoutput>
                                                      <input type="hidden" name="plw" value="#plw#"><!--- Registry_ID --->
                                                       <input type="hidden" name="qke" value="#qke#"><!--- Acct_num_temp --->
                        </cfoutput>
                                            </cfform>
                                  </cfif>
                                  <cfif Len(ksr)>
                                            <cfif Trim(uca) is "01345"><cfset WebsiteType= "Clinic"></cfif>
                    <cfif Trim(uca) is "04385"><cfset WebsiteType= "MLD"></cfif>
                    <cfif Trim(uca) is "03475"><cfset WebsiteType= "NFRD"></cfif>
                                            <div style="padding: .5em 0 .75em 0;">An email has been sent with your new password.</div>
                    <cfif Len(Trim(WebsiteType))><a href="#HTMLPath#/#WebsiteType#/LogIn.cfm">Log in</a></cfif>
                                  </cfif>
                                  </cfoutput>
                        </div><!--- min-height --->
              </div><!--- Content --->
    </div><!--- Containter --->
    <cfinclude template="../includefiles/inc_PageFooter.cfm"><!--- Page footer (contains closing tag for Container) --->

    <cfform action="index.cfm" method="POST">
    This line is going to tell the web browser to submitt the page to the web server and have the web server run the "index.cfm" page.
    The web server then expects the "index.cfm" page to expect a post request and do something with the key-value pairs contained in the header of the request.
    With a rather generaic file name like "index.cfm" it is not unlikely that the index.cfm page simply ignores the form key-value pairs and does nothing with them.  But with no way to see the server side code of this index.cfm page I can not tell for sure.

  • Need help with a recordset

    I need some help with a recordset that selects a series of
    vehicle makes that then show models when a make is selected. The
    problem is when I select the make it shows a list of models like it
    should, some of the make lists have five models and some have ten
    or more. What I need help with is how to limit the list to just the
    models and not include the "null" values. This makes my drop down
    list have large empty spaces at the end of the options listed. The
    query is as follows:
    SELECT *
    FROM saa.vehicle_make
    WHERE make = '#FORM.select_make#'
    Question # 2:
    What can I add to this recordset so that I can search on just
    the make alone without the model included. The submit includes both
    of the make and model lists so that makes it tough to break up.
    Here is the recordset:
    SELECT make
    FROM saa.vehicle_make
    ORDER BY make ASC
    Thanks
    Shane

    Sorry I guess I wasn't being clear. The lists work fine with
    the present recordsets but I was trying to clean them up just a
    little. I am using a table in mysql instead of an array for ease of
    maintenance due to the high number of makes and models I am working
    with.
    For question number one I was looking for sql that allows me
    to only show the models in the table for each make no matter how
    many are in the row. Currently when I use the existing recordset I
    get a long list of blank spaces as it is returning the "null"
    fields also. I would like it to just show the models and stop at
    the first null field.
    For the second question I wanted to be able to submit the
    form with just the make listed if someone wanted to see all Hondas
    lets say. Not I have to select the make also so it limits the
    return.
    Thanks for all of the input
    Shane
    Here is the code I am using for the two dependent select
    boxes:
    <p align="center">Vehicle Search by
    Make/Model</p>
    <!--- store the selected make variable after the first
    select boxes submits itself --->
    <cfif isDefined('form.select_make')>
    <cfset page.select_make = form.select_make>
    </cfif>
    <cfoutput>
    <form name="DropDown" method="post">
    <!--- query DB for the first drop down list --->
    <cfquery name="get_make" datasource="saa">
    SELECT make FROM saa.vehicle_make ORDER BY make ASC
    </cfquery>
    <!--- first drop down list --->
    <!--- NOTICE the onChange javascript event in the select
    tag, this is what submits the form after the first selection
    --->
    <p align="center">Model:<select name="select_make"
    required="yes" onchange="this.form.submit()">
    <option>Select Make</option>
    <!--- dynamically populate the first drop down list based
    on the get_make query --->
    <cfloop query="get_make">
    <option value="#make#" <cfif
    isDefined('form.select_make')><cfif form.select_make eq
    "#make#">selected</cfif></cfif>>#make#</option>
    </cfloop>
    </select></p>
    <!--- if the first selection has been made, display the
    second drop down list with the appropriate results --->
    <cfif isDefined('form.select_make')>
    <!--- query DB for second drop down list, based on the
    selected item from the first list --->
    <cfquery name="get_model" datasource="saa">
    SELECT * FROM saa.vehicle_make WHERE make =
    '#FORM.select_make#'
    </cfquery>
    <!--- second drop down list --->
    </cfif>
    </form>
    </cfoutput>
    <cfoutput>
    <form action="buyerModelSearchresults.cfm"
    method="POST">
    <p align="center">Model: <select name="model"
    required="yes">
    <option>Select Model</option>
    <!--- dynamically populate the second drop down list
    based on the get_make query --->
    <cfloop query="get_model">
    <option value="#model1#">#model1#</option>
    <option value="#model2#">#model2#</option>
    <option value="#model3#">#model3#</option>
    <option value="#model4#">#model4#</option>
    <option value="#model5#">#model5#</option>
    <option value="#model6#">#model6#</option>
    <option value="#model7#">#model7#</option>
    <option value="#model8#">#model8#</option>
    <option value="#model9#">#model9#</option>
    <option value="#model10#">#model10#</option>
    <option value="#model11#">#model11#</option>
    <option value="#model12#">#model12#</option>
    <option value="#model13#">#model13#</option>
    <option value="#model14#">#model14#</option>
    <option value="#model15#">#model15#</option>
    <option value="#model16#">#model16#</option>
    <option value="#model17#">#model17#</option>
    <option value="#model18#">#model18#</option>
    <option value="#model19#">#model19#</option>
    <option value="#model20#">#model20#</option>
    <option value="#model21#">#model21#</option>
    <option value="#model22#">#model22#</option>
    <option value="#model23#">#model23#</option>
    <option value="#model24#">#model24#</option>
    <option value="#model25#">#model25#</option>
    </cfloop>
    </select>
    </p>
    <p align="center">Search by Make/Model:</p>
    <p align="center"><input type="submit" name="Submit"
    value="Submit"></p>
    </form>
    </cfoutput>

  • Need help in this jquery ajax response

    Hi Below is the code i got from internet trying to test but alwys getting false alert event the record does not xist in DB.
    Below is the code
    <script language="javascript" src="jquery-1.4.2.js"></script>
        <script type="text/javascript">
                $(document).ready(function() {    
                $('#username').blur(function() {    
                            $.ajax({            
                                    type: "POST",
                                    url: "checkUser.cfc?method=checkUsername",
                                    data: "username=" + this.value,
                                    datatype: "json",
                                    success: function(response) {                                   
                                    alert(response);                                                       
                                    if (response == true) {
                                    alert("true");   
                                    //$('#usernameResponse').css('display', 'none');
                                    //$('#submit').attr('disabled','disabled');
                                    } else {
                                    alert("flase");
                                    //$('#usernameResponse').css('display', 'inline');
                                    //$('#username').select();
                                    //$('#submit').attr('disabled','disabled');
        </script>    
    <form>     <div class="formcontainer">
                      <label>User Name:</label>
                      <input type="text" name="username" id="username" />
                      <span id="usernameResponse">Sorry, that username is taken</span>
                      </div>
                      <div class="formcontainer">
                          <label>Password:</label>
                          <input type="password" name="password" id="password" />
                       </div>     
                 <div class="formcontainer">
                <input type="submit" id="submit" value="Submit" />
                    </div>
                     </form>
    CFC File:
    <cfcomponent output="false">     
        <cffunction name="getAllUsernames" access="private" returntype="query" output="false">
                     <cfset var qGetAllUsernames = queryNew('userID,username') /> 
                     <cfset queryAddRow(qGetAllUsernames, 4) /> 
                     <cfset querySetCell(qGetAllUsernames, 'userID', 1, 1) />
                     <cfset querySetCell(qGetAllUsernames, 'userName', 'John', 1) />
                     <cfset querySetCell(qGetAllUsernames, 'userID', 2, 2) />
                     <cfset querySetCell(qGetAllUsernames, 'userName', 'Paul', 2) />
                     <cfset querySetCell(qGetAllUsernames, 'userID', 3, 3) />
                     <cfset querySetCell(qGetAllUsernames, 'userName', 'George', 3) />    
                     <cfset querySetCell(qGetAllUsernames, 'userID', 4, 4) />
                     <cfset querySetCell(qGetAllUsernames, 'userName', 'Ringo', 4) />
                     <cfreturn qGetAllUsernames />
        </cffunction> 
        <cffunction name="checkUsername" access="remote" output="false" returntype="string" returnformat="JSON">
            <cfargument name="username" type="string" default="" />
            <cfset var qAllUsernames = getAllUsernames() /> 
            <cfquery name="qCheckUsername" dbtype="query">
            SELECT * FROM qAllUserNames WHERE upper(username) = <cfqueryparam value="#ucase(arguments.username)#" cfsqltype="cf_sql_varchar" />
            </cfquery>
            <cfif qCheckUsername.recordcount>
            <cfreturn true>
            <cfelse>
            <cfreturn true>       
            </cfif>       
        </cffunction>   
    </cfcomponent>
    when i run cfc alone returns result like true or false but when i try to alert that response alert box of window size with all spaces and rsult comes so not able to tet if(reponse == true does not working.
    any help will be great thanks
    this is alert box poped with response
    true
    </td></td></td></th></th></th></tr></tr></tr></table></table></table></a></abbrev></acrony m></address></applet></au></b></banner></big></blink></blockquote></bq></caption></center> </cite></code></comment></del></dfn></dir></div></div></dl></em></fig></fn></font></form>< /frame></frameset></h1></h2></h3></h4></h5></h6></head></i></ins></kbd></listing></map></m arquee></menu></multicol></nobr></noframes></noscript></note></ol></p></param></person></p laintext></pre></q></s></samp></script></select></small></strike></strong></sub></sup></ta ble></td></textarea></th></title></tr></tt></u></ul></var></wbr></xmp>

    cfnew wrote:
        <cffunction name="checkUsername" access="remote" output="false" returntype="string" returnformat="JSON">
            <cfif qCheckUsername.recordcount>
            <cfreturn true>
            <cfelse>
            <cfreturn true>       
            </cfif>       
    3 things. Do you mean perhaps:
    1) name="IsUsernameValid"
    2) returntype="boolean"
    3) <cfif qCheckUsername.recordcount>
    <cfreturn true>
    <cfelse>
    <cfreturn false>       
    </cfif>

  • Help with stopping a loop..and more :)

    I have a web site called MyNextPet.org. I want to have a
    featured pet on the
    home page that is Random
    I am attempting to write a function that does this:
    Selects the total pets in the database ('Pets') and generate
    a RecordCount
    Create a variable that is random from 1 to the RecordCount of
    'Pets'
    Attempt to select information about that pet based on the
    generated number
    (that must match the auto incremented 'pettag' number)
    If the number does not match any of the pets, loop through an
    do it again
    If the number does match, stop and output the information
    selected
    I winged this function so I am sure I did something wrong and
    the fact that
    I am posting it proves that I did. I am a little (or a lot)
    confused on how
    to break out of a loop if the condition is met.
    Help!
    Code I have:
    <cffunction name="GetFeaturedPet" access="public"
    returntype="query">
    <cfquery name="Pets" datasource="#Request.MainDSN#">
    SELECT * FROM pets
    </cfquery>
    <cfloop>
    <cfset featured = RandRange(1,#Pets.RecordCount#)>
    <cfquery name="GetFeatured"
    datasource="#Request.MainDSN#">
    SELECT P.name, p.age, p.gender, p.breed, R.org
    FROM pets P LEFT OUTER JOIN rescues R
    ON p.username = R.username
    WHERE pettag = #featured# AND active = 1
    </cfquery>
    <cfif #GetFeatured.RecordCount# EQ 0>
    </cfloop>
    </cfif>
    <cfelse>
    <cfabort>
    <cfreturn GetFeatured>
    </cffunction>
    Wally Kolcz
    Developer / Support

    Try this modified function. The first query will pull all
    active pets from your db. The second QoQ ("getPet") will pull one
    random pet from the first query.
    <cffunction name="GetFeaturedPet" access="public"
    returntype="query">
    <cfquery name="GetFeatured"
    datasource="#Request.MainDSN#">
    SELECT p.pettag, P.name, p.age, p.gender, p.breed, R.org
    FROM pets P LEFT OUTER JOIN rescues R
    ON p.username = R.username
    WHERE active = 1;
    </cfquery>
    <cfset featured =
    RandRange(1,#GetFeatured.RecordCount#)>
    <cfquery name="getPet" dbtype="query">
    SELECT * FROM GetFeatured WHERE pettag = #featured#
    </cfquery>
    <cfreturn getPet>
    </cffunction>

  • Help with OnChange in cfselect

    Hello
    I'm hoping somebody can help me.
    I am using cfform with "flash" format and what I am trying to
    do is open an edit form and requery the cfselect box onChange.
    Basically the form has a cfselect field at the top and when the
    cfselect field is changed I want the other fields on the form to be
    updated with the correct information.
    <cfformgroup type="horizontal" label="Catchment ID:">
    <cfselect enabled="yes" name="CatchmentID" tooltip="Enter
    Catchment ID" required="yes" message="Enter Catchment ID"
    multiple="no" query="getCMTQry" value="CatchmentID"
    selected="#getCMTQry.CatchmentID#">
    <option value="#getCMTQry.CatchmentID#"
    <cfif (isDefined("getCMTQry.CatchmentID")
    AND getCMTQry.CatchmentID
    EQ getCMTQry.CatchmentID)>
    </cfif>>
    </option>
    </cfselect>
    <cfinput type="text" name="CatchmentName"
    label="CatchmentName:" message="Enter Catchment Name" size="37"
    required="yes" tooltip="Enter Catchment Name">
    <cfinput type="text" name="CatchmentCostCentre"
    label="Cost Code:" value="#getCMTQry.CatchmentCostCentre#"
    tooltip="Enter Cost Code" size="10">
    </cfformgroup>
    Thank you in advance for any help.
    Diane

    What modem do you have?
    If a forum member gives an answer you like, give them the Kudos they deserve. If a member gives you the answer to your question, mark the answer as Accepted Solution so others can see the solution to the problem.
    "All knowledge is worth having."

  • Need help with hiding a form td

    I am trying to set something up where I import a csv file
    with only a bunch of ID numbers. From those numbers I query and get
    the persons name and all that. For each record I want to show a
    <select> drop down menu to choose some options. Everything
    seems to be working fine right now but if I have invalid ID numbers
    it still displays a drop down menu.
    So say I have 13 ID numbers in the csv file and 2 of them are
    invalid. It displays a form select drop down box for all 13. I want
    to hide this somehow if the numbers are invalid. Here is my code:
    <cfloop index="index" list="#csvfile#"
    delimiters="#chr(10)##chr(13)#">
    <cfset list = #listgetAt('#index#',1, ',')#>
    <cfoutput>
    <cfquery name="a" datasource="a">
    SELECT S1.Name, S1.Cardnumber
    FROM IDs S1
    WHERE S1.CardNumber = ('#list#')
    </cfquery>
    </cfoutput>
    <cfif #a.recordcount# lt 1>
    <cfoutput>Invalid ID: #list#</cfoutput>
    </cfif>
    <cfquery name="b" datasource="a">
    select Level
    from IDsAccLevels
    where ID = '#userid#'
    ORDER BY Level
    </cfquery>
    Any help or ideas would be appreciated.
    <cfoutput query="a">
    <tr>
    <td align = "left" style="PADDING-LEFT:
    5px">#CardNumber#</td>
    <td style="PADDING-LEFT: 5px">#Name#</td>
    </cfoutput>
    <form name="test" method="post" action="schedule.cfm"
    target="_self" ID="testrow">
    <td height=21 class="pad5">
    <select name="bldgarea">
    <cfoutput query="b">
    <option value="#Level#">
    #Level# </option>
    </cfoutput>
    </cfif>
    </cfloop>
    </select>
    </form>
    </td>
    </td>
    </tr>

    quote:
    Originally posted by:
    siriiven
    Isn't that what I am doing now?
    No. You are looping through a list, and running individual
    queries inside that loop.

  • Help with REGEX to block invalid characters

    I have a regex that is used to block unusual characters from being entered into a user name, so they can put pipes etc in there, I just want 0-9 and a-z (upper or lowercase), but I just noticed that it's not working. I am not up to speed on regex, I took this from somewhere else
    here is the expression:
    <cfif len(trim(ReReplaceNocase(form_username, '^[A-Za-z][A-Za-z0-9_]*', '', 'ALL'))) gt 0>
    It is failing when I enter 2kljlkll3456 as the username
    Anybody have any idea why it's not working?
    After posing this I found out that the issue is that it does not allo me to have a username that starts with a number, only a letter, anybody have any idea how to fix that?
    Thanks
    Mark

    Hey Dan,
    I found a link that explained how the regex is actually formed which helped!
    http://stackoverflow.com/questions/336210/regular-expression-for-alphanumeric-and-undersco res
    Now I have managed to get a basic understanding of how they are formed the fix was easy
    I had:
    <cfif len(trim(ReReplaceNocase(form_username, '^[A-Za-z][A-Za-z0-9_]*', '', 'ALL'))) gt 0>
    But should have had
    <cfif len(trim(ReReplaceNocase(form_username, '^[A-Za-z0-9_]*', '', 'ALL'))) gt 0>
    Simply removing [A-Za-z] from the start fixed it. I get it now ... so the first section defined the first character which was restricted to A-Za-z only.
    I'll mark this as answered
    Thanks
    Mark

Maybe you are looking for