Solved

need to create dynamic cfarguments

Posted on 2008-06-19
9
635 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

 
LVL 36

Accepted Solution

by:
SidFishes earned 500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
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’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

617 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