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.
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>
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.curr entrow#" value="#trim(QGetJobI.Plac ement_Stat us)#" size="2" /><cfinput type="hidden" name="individual_number#QG etJobI.cur rentrow#" value="#QGetJobI.individua l_number#" /></td>
<td><cfinput type="text" name="name#QGetJobI.curren trow#" value="#trim(QGetJobI.firs tname)# #trim(QGetJobI.lastname)#" size="30"/></td>
<td><cfinput type="text" name="Date_Of_Resume#QGetJ obI.curren trow#" value="#dateformat(QGetJob I.date_of_ resume,"yy yy/mm/dd") #" size="10"/></td>
<td><cfinput type="text" name="Date_Telephoned#QGet JobI.curre ntrow#" value="#dateformat(QGetJob I.date_tel ephoned,"y yyy/mm/dd" )#" size="10"/></td>
<td><cfinput type="text" name="Date_Of_Face_To_Face #QGetJobI. currentrow #" value="#dateformat(QGetJob I.date_of_ face_to_fa ce,"yyyy/m m/dd")#" size="10"/></td>
<td><cfinput type="text" name="Date_Of_Placement#QG etJobI.cur rentrow#" value="#dateformat(QGetJob I.date_of_ placement, "yyyy/mm/d d")#" size="10"/><cfinput type="hidden" name="Old_Date_Of_Placemen t#QGetJobI .currentro w#" value="#QGetJobI.date_of_p lacement#" /></td>
<td><cfselect name="Individual_recruiter _referal#Q GetJobI.cu rrentrow#" query="QconsultantList" multiple="no" display="username" selected ="#QGetJobI.Individual_rec ruiter_ref eral#" size="1" value="adminid"></cfselect ></td>
<td><cfselect name="Individual_recruiter #QGetJobI. currentrow #" query="QconsultantList" multiple="no" display="username" selected ="#QGetJobI.Individual_rec ruiter#" size="1" value="adminid"></cfselect ></td>
<td><cfselect name="Individual_consultan t#QGetJobI .currentro w#" query="QconsultantList" multiple="no" display="username" selected ="#QGetJobI.Individual_con sultant#" size="1" value="adminid"></cfselect ></td>
<td><cfinput type="text" name="active_until#QGetJob I.currentr ow#" value="#dateformat(QGetJob I.active_u ntil,"yyyy /mm/dd")#" size="12"/></td>
<td><cfinput name="DeleteIndiv#QGetJobI .currentro w#" type="checkbox"></td>
</tr>
</cfoutput>
<cfinput type="hidden" name="SearchIndivsRecordCo unt" value="#QGetJobI.recordcou nt#" />
</table>
But, you were close.
<cfoutput query="QGetJobI">
<tr>
<td><cfinput type="text" name="status#QGetJobI.curr
<td><cfinput type="text" name="name#QGetJobI.curren
<td><cfinput type="text" name="Date_Of_Resume#QGetJ
<td><cfinput type="text" name="Date_Telephoned#QGet
<td><cfinput type="text" name="Date_Of_Face_To_Face
<td><cfinput type="text" name="Date_Of_Placement#QG
<td><cfselect name="Individual_recruiter
<td><cfselect name="Individual_recruiter
<td><cfselect name="Individual_consultan
<td><cfinput type="text" name="active_until#QGetJob
<td><cfinput name="DeleteIndiv#QGetJobI
</tr>
</cfoutput>
<cfinput type="hidden" name="SearchIndivsRecordCo
</table>
ASKER
There always seems to be one more thing. At the bottom of the previous code there is a checkbox, "DeleteIndiv#QGetJobI.curr entrow#". 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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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>
ASKER
Oh yeah;
<td><cfinput name="DeleteYN#QGetJobI.cu rrentrow#" type="hidden" value="off">
<cfinput name="DeleteIndiv#QGetJobI .currentro w#" type="checkbox" onClick="changeTF(#QGetJob I.currentr ow#)"></td >
<td><cfinput name="DeleteYN#QGetJobI.cu
<cfinput name="DeleteIndiv#QGetJobI
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>
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.
<script type="text/javascript" language="JavaScript">
function changeTF(elementindex){
var theObj = document.forms.DspSearch['
theObj.value = (theObj.value!='on')?'on':
alert (theObj.value);
return;
}
</script>
Thanks very much for your help. I've been spinning my wheels for hours. Problem solved
Thanks again.
ASKER
Wouldn't want to weigh in on a Spry problem, would you?
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#
</td>
</cfloop>
</tr>
</table>
</cfoutput>