Link to home
Start Free TrialLog in
Avatar of larksys
larksys

asked on

need to create dynamic cfarguments

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

Avatar of SidFishes
SidFishes
Flag of Canada image

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>

Avatar of larksys
larksys

ASKER

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>
Avatar of larksys

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of SidFishes
SidFishes
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of larksys

ASKER

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

Avatar of larksys

ASKER

Oh yeah;

<td><cfinput name="DeleteYN#QGetJobI.currentrow#" type="hidden" value="off">
                        <cfinput name="DeleteIndiv#QGetJobI.currentrow#" type="checkbox" onClick="changeTF(#QGetJobI.currentrow#)"></td>
Avatar of larksys

ASKER

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

Avatar of larksys

ASKER

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.
Avatar of larksys

ASKER

Wouldn't want to weigh in on a Spry problem, would you?