Improve company productivity with a Business Account.Sign Up

x
?
Solved

need to create dynamic cfarguments

Posted on 2008-06-19
9
Medium Priority
?
646 Views
Last Modified: 2008-06-20
I tried using cfgrid but it's worthless in the real world unless you're just doing simple display and/or updates. So I went back to using a dynamic table with TDs based on a query. The problem is updating the data. I tried to use list functions but empty TDs are not passed and that creates a problem stepping through multiple lists using just one index. The elements don't match up. So I thought I would I would create the cfinputs inside the TDs with a name plus the currentrow from the query (I/E field1, field2, etc.). The problem is the update cfc. I can't create dynamic cfarguments.

 Context validation error for the cfargument tag.
The tag must be nested inside a CFFUNCTION tag.
<cffunction name="updateSearch" access="remote">
        <cfargument name="SearchIndivsRecordCount" type="string" required="no">
    <cfif #arguments.SearchIndivsRecordCount# gt 0>
        <cfargument name="SEARCHNUM" type="string" required="yes">
        <cfargument name="Company_number" type="string" required="no">
        <cfargument name="title" type="string" required="no">
        <cfargument name="reportstoid" type="string" required="no">
        <cfargument name="hrid" type="string" required="no">
        <cfargument name="haid" type="string" required="no">
        <cfargument name="active" type="string" required="no">
        <cfargument name="invoice_to_individual" type="string" required="no">
        <cfargument name="search_begin_date" type="string" required="no">
        <cfargument name="date_accepted" type="string" required="no">
        <cfargument name="tax_specialty" type="string" required="no">
        <cfargument name="low_salary" type="string" required="no">
        <cfargument name="high_salary" type="string" required="no">
        <cfargument name="relocate_yn" type="string" required="no">
        <cfargument name="paid_yn" type="string" required="no">
        <cfargument name="buy_house_yn" type="string" required="no">
        <cfargument name="start_date" type="string" required="no">
        <cfargument name="start_salary" type="string" required="no">
        <cfargument name="additional_compensation" type="string" required="no">
        <cfargument name="recruiter_referal" type="string" required="no">
        <cfargument name="consultant_referal" type="string" required="no">
        <cfargument name="fill_consultant" type="string" required="no">
        <cfargument name="recruiter_referring_individual" type="string" required="no">
        <cfargument name="recruiter_working_individual" type="string" required="no">
        <cfargument name="consultant_working_individual" type="string" required="no">
        <cfargument name="candidate_placed_number" type="string" required="no">
        <cfargument name="reports_to" type="string" required="no">
 
        <cfloop from="1" to="#arguments.SearchIndivsRecordCount#" index="sirc">
            <cfargument name="individual_number#sirc#" type="string" required="no">
            <cfargument name="date_of_resume#sirc#" type="string" required="no">
            <cfargument name="date_telephoned#sirc#" type="string" required="no">
            <cfargument name="date_of_Face_to_face#sirc#" type="string" required="no">
            <cfargument name="date_of_placement#sirc#" type="string" required="no">
            <cfargument name="old_date_of_placement#sirc#" type="string" required="no">
            <cfargument name="Individual_recruiter_referal#sirc#" type="string" required="no">
            <cfargument name="Individual_recruiter#sirc#" type="string" required="no">
            <cfargument name="Individual_consultant#sirc#" type="string" required="no">
            <cfargument name="DeleteIndiv#sirc#" type="string" required="no">
            <cfif #trim(arguments.Date_of_placement#sirc#)# neq #trim(arguments.Old_Date_of_placement#sirc#)#>
                <cfset arguments.candidate_placed_number = "#arguments.individual_number#sirc##" />
            </cfif>
        </cfloop>
        <cfelse>
        <cfargument name="SEARCHNUM" type="string" required="yes">
        <cfargument name="Company_number" type="string" required="no">
        <cfargument name="title" type="string" required="no">
        <cfargument name="reportstoid" type="string" required="no">
        <cfargument name="hrid" type="string" required="no">
        <cfargument name="haid" type="string" required="no">
        <cfargument name="active" type="string" required="no">
        <cfargument name="invoice_to_individual" type="string" required="no">
        <cfargument name="search_begin_date" type="string" required="no">
        <cfargument name="date_accepted" type="string" required="no">
        <cfargument name="tax_specialty" type="string" required="no">
        <cfargument name="low_salary" type="string" required="no">
        <cfargument name="high_salary" type="string" required="no">
        <cfargument name="relocate_yn" type="string" required="no">
        <cfargument name="paid_yn" type="string" required="no">
        <cfargument name="buy_house_yn" type="string" required="no">
        <cfargument name="start_date" type="string" required="no">
        <cfargument name="start_salary" type="string" required="no">
        <cfargument name="additional_compensation" type="string" required="no">
        <cfargument name="recruiter_referal" type="string" required="no">
        <cfargument name="consultant_referal" type="string" required="no">
        <cfargument name="fill_consultant" type="string" required="no">
        <cfargument name="recruiter_referring_individual" type="string" required="no">
        <cfargument name="recruiter_working_individual" type="string" required="no">
        <cfargument name="consultant_working_individual" type="string" required="no">
        <cfargument name="candidate_placed_number" type="string" required="no">
        <cfargument name="reports_to" type="string" required="no">
 
    </cfif>

Open in new window

0
Comment
Question by:larksys
  • 7
  • 2
9 Comments
 
LVL 36

Expert Comment

by:SidFishes
ID: 21830860
afaik this is not possible as cfarguments must be the first tags following cffunction

If I understand what ou are trying to do, maybe dynamically set your form and just pass key pair changes to each cell via ajax? something like

      
<script type="text/javascript">
function make_request()
{
      alert( make_request.arguments[0] + "," + make_request.arguments[1])
      //do you ajax call here
}

</script>
<cfoutput>

<cfset TempQry= querynew("")>
<cfset queryaddcolumn  (TempQry, "initValueID", "CF_SQL_integer", ListToArray("1,2,3,4,5,6"))>
<cfset queryaddcolumn  (TempQry, "initValue", "cf_sql_varchar", ListToArray("here, there, everywhere, nowhere, anywhere,somewhere"))>
<table>
<tr>
<cfloop query="tempqry">
<td>
      <input type="text"       value="#initValue#" onblur ="make_request('fieldName#InitValueID#',this.value);">
</td>
</cfloop>
</tr>
</table>
</cfoutput>

0
 
LVL 1

Author Comment

by:larksys
ID: 21831093
I have a form that submits to an action (update) form that invokes the update cfc function. If I hadn't been so hyper about it I would have realized that replacing the invoke with the query update on the action page would solve the problem.

But, you were close.

 <cfoutput query="QGetJobI">
                <tr>
                    <td><cfinput type="text" name="status#QGetJobI.currentrow#" value="#trim(QGetJobI.Placement_Status)#" size="2" /><cfinput type="hidden" name="individual_number#QGetJobI.currentrow#" value="#QGetJobI.individual_number#"/></td>
                    <td><cfinput type="text" name="name#QGetJobI.currentrow#" value="#trim(QGetJobI.firstname)# #trim(QGetJobI.lastname)#" size="30"/></td>
                    <td><cfinput type="text" name="Date_Of_Resume#QGetJobI.currentrow#" value="#dateformat(QGetJobI.date_of_resume,"yyyy/mm/dd")#" size="10"/></td>
                    <td><cfinput type="text" name="Date_Telephoned#QGetJobI.currentrow#" value="#dateformat(QGetJobI.date_telephoned,"yyyy/mm/dd")#" size="10"/></td>
                    <td><cfinput type="text" name="Date_Of_Face_To_Face#QGetJobI.currentrow#" value="#dateformat(QGetJobI.date_of_face_to_face,"yyyy/mm/dd")#" size="10"/></td>
                    <td><cfinput type="text" name="Date_Of_Placement#QGetJobI.currentrow#" value="#dateformat(QGetJobI.date_of_placement,"yyyy/mm/dd")#" size="10"/><cfinput type="hidden" name="Old_Date_Of_Placement#QGetJobI.currentrow#" value="#QGetJobI.date_of_placement#"/></td>
                    <td><cfselect name="Individual_recruiter_referal#QGetJobI.currentrow#" query="QconsultantList" multiple="no" display="username" selected ="#QGetJobI.Individual_recruiter_referal#" size="1" value="adminid"></cfselect></td>
                    <td><cfselect name="Individual_recruiter#QGetJobI.currentrow#" query="QconsultantList" multiple="no" display="username" selected ="#QGetJobI.Individual_recruiter#" size="1" value="adminid"></cfselect></td>
                    <td><cfselect name="Individual_consultant#QGetJobI.currentrow#" query="QconsultantList" multiple="no" display="username" selected ="#QGetJobI.Individual_consultant#" size="1" value="adminid"></cfselect></td>
                    <td><cfinput type="text" name="active_until#QGetJobI.currentrow#" value="#dateformat(QGetJobI.active_until,"yyyy/mm/dd")#" size="12"/></td>
               
                <td><cfinput name="DeleteIndiv#QGetJobI.currentrow#" type="checkbox"></td>
           
            </tr>
            </cfoutput>
            <cfinput type="hidden" name="SearchIndivsRecordCount" value="#QGetJobI.recordcount#" />
        </table>
0
 
LVL 1

Author Comment

by:larksys
ID: 21833260
There always seems to be one more thing. At the bottom of the previous code there is a checkbox, "DeleteIndiv#QGetJobI.currentrow#". It does not pass in the form scope if it is not checked. I need a method or trick to tell me to delete that line upon the users instruction so I will have an element that matches the others when looping through the elements. I guess I could have a cfinput where the user could type a "D" but that seems so passe. Can I do  cfparam just above the TD that will always create the element whether they check it or not?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 36

Accepted Solution

by:
SidFishes earned 2000 total points
ID: 21833598
don't think so, the checkbox will only pass an ON value and only if checked.

you could try something with a hidden field and some js

ie: have a hidden field called checkboxdelete=true
and then just set it to false (or better to toggle t/f) with js when the checkbox is checked

eval that field in the form and if = true then skip the line

0
 
LVL 1

Author Comment

by:larksys
ID: 21834793
I'm just not good enough at JS. Maybe you can solve the problem. I'm having trouble accessing a variable element name in the script.



It tells me that the left hand side of the argument is invalid. And no alert pops up.
function changeTF(elementindex){
var EI = elementindex;
if (document.forms['DspSearch'].DeleteYN + EI.value == 'on')
{
alert (document.forms['DspSearch'].DeleteYN + EI.value);
 document.forms['DspSearch'].DeleteYN + EI.value = 'off';}   <----------
 else{
 alert (document.forms['DspSearch'].DeleteYN + EI.value);
  document.forms['DspSearch'].DeleteYN + EI.value = 'on';}
return;
}
</script>

Open in new window

0
 
LVL 1

Author Comment

by:larksys
ID: 21834859
Oh yeah;

<td><cfinput name="DeleteYN#QGetJobI.currentrow#" type="hidden" value="off">
                        <cfinput name="DeleteIndiv#QGetJobI.currentrow#" type="checkbox" onClick="changeTF(#QGetJobI.currentrow#)"></td>
0
 
LVL 1

Author Comment

by:larksys
ID: 21835068
When debugging I find that elementindex is passing properly and the end result element name is DeleteYN1. I just can't figure out how to get to the element to change it.
<script type="text/javascript" language="JavaScript">        
function changeTF(elementindex){
var EI = elementindex;
var EIname = 'DeletYN' + EI;
var x = document.getElementsByName(EIname).value;
/*if (document.forms['DspSearch'].[EIname].value == 'on')
{*/
alert (EIname);
/* document.forms['DspSearch'].[EIname].value = 'off';}
 else{
 alert (document.forms['DspSearch'].[EIname].value);
  document.forms['DspSearch'].[EIname].value = 'on';}*/
return;
}
</script>

Open in new window

0
 
LVL 1

Author Comment

by:larksys
ID: 21836068
Got a little help from the JS guys.

<script type="text/javascript" language="JavaScript">        
function changeTF(elementindex){
  var theObj = document.forms.DspSearch['DeleteYN' + elementindex];
  theObj.value = (theObj.value!='on')?'on':'off';
  alert (theObj.value);
  return;
}
</script>


Thanks very much for your help. I've been spinning my wheels for hours. Problem solved

Thanks again.
0
 
LVL 1

Author Comment

by:larksys
ID: 21836072
Wouldn't want to weigh in on a Spry problem, would you?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
If you are looking for an automated solution for backup single or multiple Office 365 user mailboxes to Outlook data file, then you can use Kernel Office 365 Backup & Restore tool. Go through the video to check out the steps to backup single or mult…
To export Lotus Notes to Outlook PST or Exchange and Domino Server files to Exchange Server or PST files with ease, go for Kernel for Lotus Notes to Outlook conversion tool. Through the video, you can watch the conversion process. A common user with…

606 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question