I need a javascript button to move data from one table to another

I currently have a submit button that will move a field or all fields from the table on the left to the table on the right.  I need to replace it with a javascript function.  this is my javascript function:

            function custRpt()
            {
              document.Form1.action = 'custRpt.cfm';
              document.Form1.submit();
            }

I have attached a copy of the cfm page.  When I click on a field and click on the javascript link I created nothing happens.  Same when I click the add all button.  I'm new to this so I'm not sure what I'm doing wrong.  
<script language="javascript" src="inc/dcd.js"></script>
<link href="https://www.sovereignbank.com/inc/all.css" rel="stylesheet" type="text/css">
<style type="text/css"></style>
 
<cfset #pageTitle# = "Administration">
<cfset #curPage# = 77>
<cfset #custContent# = "AP1">
 
<cfset #LbxName# = RemoveChars(#session.lbxformattable#,1,8)>
<!---<cfif #Session.lbxtype# is "Wholesale">--->
<cfset #RptTableName# = "lbx_rpt_#LbxName#">
<!---<cfelse>
<cfset #RptTableName# = "rlb_rpt_#LbxName#">
</cfif>--->
 
<cfquery name = "checkforrpttable" datasource="#Application.dsname#">
  SELECT * from sysobjects where name = '#RptTableName#'
</cfquery>
 
<cfif #checkforrpttable.Recordcount# is 0>
  <cfquery name = "createrpttable" datasource = "#Application.dsname#">
     SELECT * INTO #RptTableName# FROM #SESSION.LBXFORMATTABLE#
  </cfquery>
<cfelse>
  <cfquery name = "comparefmt" datasource = "#Application.dsname#">
      SELECT * FROM #Session.LbxFormatTable# T1 
	        WHERE (T1.layout = 'AP') AND 
			NOT EXISTS(SELECT * FROM #RptTableName# T2 where (T1.fld_order = T2.fld_order) and layout='AP')
  </cfquery>
  <cfif #comparefmt.RecordCount# gt 0>
     <cfquery name = "insertintoReportTable" datasource = "#Application.dsname#">
	     INSERT INTO #RptTableName#(layout,fld_order,fld_name,fld_otype,fld_len,fld_dec,fld_prompt,fld_head1,fld_head2,can_modify,can_search,at_info,at_caption,at_trans,at_chkbody,at_invbody,at_cpnbody,at_support,at_report,rollup,total)
    	   (SELECT * FROM 
			    #Session.LbxFormatTable# T1 
				WHERE (T1.layout = 'AP') AND 
				NOT EXISTS(SELECT * FROM #RptTableName# T2 where (T1.fld_order = T2.fld_order) and layout='AP'))
	 </cfquery>
  <cfelse>
	  <cfquery name = "comparerpt" datasource = "#Application.dsname#">
    	  SELECT * FROM #RptTableName# T1 
	    	    WHERE (T1.layout = 'AP') AND 
				NOT EXISTS(SELECT * FROM #Session.LbxFormatTable# T2 where (T1.fld_order = T2.fld_order)and layout='AP')
	  </cfquery>
 
  	<cfif #comparerpt.RecordCount# gt 0>
    	<cfloop query = "comparerpt">
		<cfquery name="Del" datasource="#Application.dsname#">
	   		DELETE  FROM #RPTTableName# where (fld_order = #comparerpt.fld_order#) and (layout = 'AP')
		</cfquery>
		</cfloop>
	</cfif>
  </cfif>
  
  <cfquery name ="checkforcan_search" datasource="#Application.dsname#">
     SELECT T2.fld_name,T2.layout,T2.fld_order,T2.can_search FROM #RptTableName# T1,#Session.lbxFormatTable# T2 WHERE 
	    (T1.layout = T2.layout) And (T1.layout = 'AP') AND
		(T2.can_search <> T1.can_search) AND (T1.fld_name = T2.fld_name) 
		ORDER BY T1.fld_order
  </cfquery>
  
  <cfif #checkforcan_search.RecordCount# gt 0>
    <cfloop query = "checkforcan_search">
	
   <cfquery name = "updaterpttable" datasource= "#Application.dsname#">
            UPDATE #RptTableName#  SET can_search = #checkforcan_search.can_search#
                 WHERE (layout = 'AP') AND
     		           (fld_name = '#checkforcan_search.fld_name#')
	</cfquery>
	</cfloop>
  </cfif>
</cfif>
 
 
<cfif #ParameterExists(form.add)# AND #Len(Trim(form.add))# gt 0>
<!--- added isDefine to make sure form.flds exist --->
<cfif isdefined("form.Flds")>
  <cfset #form.reportFields#="#form.reportFields#,#form.flds#">
</cfif>
 </cfif>
<cfif #ParameterExists(form.addAll)# AND #Len(Trim(form.addAll))# gt 0>
  <cfquery name="getAll" datasource="#Application.dsname#">
    <!---SELECT fld_name, layout, can_search FROM #session.lbxformattable# WHERE layout='AP' AND can_search=1--->
	SELECT fld_name, layout, can_search FROM #RptTableName# WHERE layout='AP' AND can_search=1
  </cfquery>
  <cfset #lcv# = 1>
  <cfloop query="getAll">
    <cfquery name="updateAll" datasource="#Application.dsname#">
      <!---UPDATE #session.lbxformattable# SET at_report=#lcv# WHERE layout='AP' AND fld_name='#getAll.fld_name#'--->
	  UPDATE #RptTableName# SET at_report=#lcv# WHERE layout='AP' AND fld_name='#getAll.fld_name#'
    </cfquery>
    <cfset #lcv# = #lcv# + 1>
  </cfloop>
</cfif>
 
<cfif #ParameterExists(form.remove)# AND #Len(Trim(form.remove))# gt 0>
<!--- added isDefine to make sure form.rptflds exist --->
<cfif isdefined("form.rptFlds")>
  <cfset #tmpList# = #form.reportFields#>
  <cfset #tmpFindVal# = #ListFindNoCase(tmpList, form.rptFlds, ",")#>
  <cfif #tmpFindVal# gt 0>
    <cfset #form.reportFields# = #ListDeleteAt(tmpList, tmpFindVal, ",")#>
    <cfquery name="remove" datasource="#Application.dsname#">
      <!---UPDATE #session.lbxformattable# SET at_report=0 WHERE layout='AP'--->
	  UPDATE #RptTableName# SET at_report=0 WHERE layout='AP'
    </cfquery>
	 </cfif> 		
  </cfif>
</cfif>
 
<cfif #ParameterExists(form.removeAll)# AND #Len(Trim(form.removeAll))# gt 0>
  <cfset #form.reportFields# = "">
  <cfquery name="removeAll" datasource="#Application.dsname#">
    <!---UPDATE #session.lbxformattable# SET at_report=0 WHERE layout='AP'--->
	UPDATE #RptTableName# SET at_report=0 WHERE layout='AP'
  </cfquery>
</cfif>
 
<cfif (#ParameterExists(form.finished)# AND #Len(Trim(form.finished))# gt 0) OR
      (#ParameterExists(form.add)# AND #Len(Trim(form.add))# gt 0) OR
      (#ParameterExists(form.remove)# AND #Len(Trim(form.remove))# gt 0) OR
      (#ParameterExists(form.removeAll)# AND #Len(Trim(form.removeAll))# gt 0)>
 
  <cfset #lcv# = 0>
  <cfloop index="fldName" list="#form.reportFields#">
    <cfoutput>
      <cfset #lcv# = #lcv# + 1>
      <cfquery name="addRptFields" datasource="#application.dsname#">
        <!---UPDATE #session.lbxformattable# SET at_report=#lcv# WHERE fld_name='#fldName#' AND layout='AP'--->
		UPDATE #RptTableName# SET at_report=#lcv# WHERE fld_name='#fldName#' AND layout='AP'
      </cfquery>
    </cfoutput>
  </cfloop>
</cfif>
 
<cfif #ParameterExists(form.finished)# AND #Len(Trim(form.finished))# gt 0>
  <cfif #ParameterExists(form.reportFields)# AND #Len(Trim(form.reportFields))# gt 0>
    <cfset #tmpUrl# = "custRpt.cfm?errMsg=Custom%20report%20updated">
  <cfelse>
    <cfset #tmpUrl# = "custRpt.cfm?errMsg=Unable%20to%20update%20custom%20report">
  </cfif>
  <cflocation url="#tmpUrl#">
<cfelse>
  <cfinclude template="intra-main2.cfm">
 
  <cfquery name="getMaxFields" datasource="#Application.dsname#">
    <!---SELECT fld_name, layout, can_search FROM #session.lbxformattable# WHERE layout='AP' AND can_search=1--->
	SELECT fld_name, layout, can_search FROM #RptTableName# WHERE layout='AP' AND can_search=1
  </cfquery>
 
  <cfquery name="getFields" datasource="#application.dsname#">
    <!---SELECT * FROM #session.lbxformattable# WHERE layout='AP' and can_search=1 AND at_report=0 ORDER BY fld_name--->
	SELECT * FROM #RptTableName# WHERE layout='AP' and can_search=1 AND at_report=0 ORDER BY fld_name
  </cfquery>
 
  <cfquery name="getRptFields" datasource="#application.dsname#">
    <!---SELECT * FROM #session.lbxformattable# WHERE layout='AP' and at_report>0 ORDER BY at_report--->
	SELECT * FROM #RptTableName# WHERE layout='AP' and at_report>0 ORDER BY at_report
  </cfquery>
 
  <p><br></p>
  <cfif #ParameterExists(URL.errMsg)# AND #Len(Trim(URL.errMsg))# gt 0>
    <p><div align="center"><font color="#Application.emphtext#"><b><cfoutput>#URL.errMsg#</cfoutput></b></font></div></p>
  </cfif>
  <p><br></p>
 
  <CFSET tmpReportFields = #ValueList(getRptFields.fld_name)#>
 
  <table style="border:1px solid #d1cdc6; margin-left:10px;">
    <form name="Form1" method="post" action="custRpt.cfm">
      <input type="hidden" name="reportFields" value="<cfoutput>#tmpReportFields#</cfoutput>">
      <tr>
        <td><font size="-2"><b>Available Fields:</b></font></td>
        <td>&nbsp;</td>
        <td><font size="-2"><b>Selected Fields:</b></font></td>
      </tr>
      <tr>
        <td valign="top" bordercolor="#d1cdc6">
          <select name="flds" size="<cfoutput>#getMaxFields.RecordCount#</cfoutput>">
            <cfif #getFields.RecordCount# is 0>
              <option value="">-- All Selected --</option>
            <cfelse>
              <cfoutput query="getFields">
                <option value="#getFields.fld_name#">#getFields.fld_head1#&nbsp;#getFields.fld_head2#</option>
              </cfoutput>
            </cfif>
          </select>
        </td>
        <td valign="top">
		  <a href="javascript:document.Form1.submit()" class="red10"><img src="images/double_arrow1_left.gif" border="0">&nbsp;Remove</a>		
          <p><input type="submit" class="red10" name="add" value="      >     "></p>
		  <a href="javascript: custRpt()" class="red10"><img src="images/double_arrow1_left.gif" border="0">&nbsp;Remove All</a>		
          <p><input type="submit" class="red10" name="addAll" value="    >>    "></p>
		  <a href="javascript: custRpt()" class="red10">Add&nbsp;<img src="images/double_arrow.gif" border="0"></a>		
          <p><input type="submit" class="red10" name="remove" value="     <      "></p>
		  <a href="javascript: custRpt()" class="red10">Add All&nbsp;<img src="images/double_arrow.gif" border="0"></a>		
          <p><input type="submit" class="red10" name="removeall" value="    <<    "></p>
        </td>
        <td valign="top" bordercolor="#d1cdc6">
          <select name="rptFlds" size="<cfoutput>#getMaxFields.RecordCount#</cfoutput>">
            <cfif #getRptFields.RecordCount# is 0>
              <option value="">-- None Selected --</option>
            <cfelse>
              <cfoutput query="getRptFields">
                <option value="#getRptFields.fld_name#">#getRptFields.fld_head1#&nbsp;#getRptFields.fld_head2#</option>
              </cfoutput>
            </cfif>
          </select>
        </td>
      </tr>
    </form>
  </table>
  <p><br /></p>
  <cfinclude template="footer.cfm">
</cfif>

Open in new window

CashmgmtAsked:
Who is Participating?
 
Mr_NilConnect With a Mentor Commented:
Here you go...

I'm not guaranteeing that its perfect, but it should be pretty close to what you need.

I popped the function into the top of the page for you and sorted out the CFML.

Hope it helps
<script language="javascript" src="inc/dcd.js"></script>
<script language="javascript">
function custRpt(moveaction) {
   document.Form1.moveaction.value = moveaction;
   document.Form1.action = 'custRpt.cfm';
   document.Form1.submit();
}
</script>
<link href="https://www.sovereignbank.com/inc/all.css" rel="stylesheet" type="text/css">
<style type="text/css"></style>
 
<cfset pageTitle = "Administration">
<cfset curPage = 77>
<cfset custContent = "AP1">
 
<cfset LbxName = RemoveChars(session.lbxformattable,1,8)>
<cfset RptTableName = "lbx_rpt_"&LbxName />
 
<cfquery name = "checkforrpttable" datasource="#Application.dsname#">
  SELECT * from sysobjects 
  where name = '#RptTableName#'
</cfquery>
 
<cfif checkforrpttable.Recordcount is 0>
  <cfquery name = "createrpttable" datasource = "#Application.dsname#">
     SELECT * INTO #RptTableName# 
	 FROM #SESSION.LBXFORMATTABLE#
  </cfquery>
<cfelse>
	<cfquery name = "comparefmt" datasource = "#Application.dsname#">
	    SELECT * FROM #Session.LbxFormatTable# T1 
	    WHERE (T1.layout = 'AP') AND 
	         NOT EXISTS(SELECT * FROM #RptTableName# T2 where (T1.fld_order = T2.fld_order) and layout='AP')
	</cfquery>
	
	<cfif comparefmt.RecordCount gt 0>
		<cfquery name = "insertintoReportTable" datasource = "#Application.dsname#">
		INSERT INTO #RptTableName#
		(layout,fld_order,fld_name,fld_otype,fld_len,fld_dec,fld_prompt,fld_head1,fld_head2,can_modify,can_search,at_info,at_caption,at_trans,at_chkbody,at_invbody,at_cpnbody,at_support,at_report,rollup,total)
		   (SELECT * FROM #Session.LbxFormatTable# T1 
		    WHERE (T1.layout = 'AP') AND 
		          NOT EXISTS(SELECT * FROM #RptTableName# T2 where (T1.fld_order = T2.fld_order) and layout='AP'))
		</cfquery>
	<cfelse>
	    <cfquery name = "comparerpt" datasource = "#Application.dsname#">
	    SELECT * FROM #RptTableName# T1 
	              WHERE (T1.layout = 'AP') AND 
	                          NOT EXISTS(SELECT * FROM #Session.LbxFormatTable# T2 where (T1.fld_order = T2.fld_order)and layout='AP')
	    </cfquery>
 
		<cfif comparerpt.RecordCount gt 0>
			<cfloop query = "comparerpt">
				<cfquery name="Del" datasource="#Application.dsname#">
				DELETE  FROM #RPTTableName# 
				where (fld_order = #comparerpt.fld_order#) and (layout = 'AP')
				</cfquery>
			</cfloop>
		</cfif>
	</cfif>
  
	<cfquery name ="checkforcan_search" datasource="#Application.dsname#">
	   SELECT T2.fld_name,T2.layout,T2.fld_order,T2.can_search FROM #RptTableName# T1,#Session.lbxFormatTable# T2 WHERE 
	          (T1.layout = T2.layout) And (T1.layout = 'AP') AND
	              (T2.can_search <> T1.can_search) AND (T1.fld_name = T2.fld_name) 
	              ORDER BY T1.fld_order
	</cfquery>
  
  <cfif #checkforcan_search.RecordCount# gt 0>
    <cfloop query = "checkforcan_search">
        
   <cfquery name = "updaterpttable" datasource= "#Application.dsname#">
            UPDATE #RptTableName#  SET can_search = #checkforcan_search.can_search#
                 WHERE (layout = 'AP') AND
                           (fld_name = '#checkforcan_search.fld_name#')
        </cfquery>
        </cfloop>
  </cfif>
</cfif>
 
 
<cfif StructKeyExists(form,"moveaction") AND form.moveaction EQ "add">
	<!--- added isDefine to make sure form.flds exist --->
	<cfif StructKeyExists(form,"Flds")>
		<cfset form.reportFields=form.reportFields&","&form.flds />
	</cfif>
</cfif>
 
<cfif StructKeyExists(form,"moveaction") AND form.moveaction EQ "addall">
  <cfquery name="getAll" datasource="#Application.dsname#">
    <!---SELECT fld_name, layout, can_search FROM #session.lbxformattable# WHERE layout='AP' AND can_search=1--->
        SELECT fld_name, layout, can_search 
		FROM #RptTableName# WHERE layout='AP' AND can_search=1
  </cfquery>
  <cfset lcv = 1>
  <cfloop query="getAll">
    <cfquery name="updateAll" datasource="#Application.dsname#">
        UPDATE #RptTableName# SET at_report=#lcv# 
		WHERE layout='AP' AND fld_name='#getAll.fld_name#'
    </cfquery>
    <cfset #lcv# = #lcv# + 1>
  </cfloop>
</cfif>
 
<cfif StructKeyExists(form,"moveaction") AND form.moveaction EQ "remove">
	<!--- added isDefine to make sure form.rptflds exist --->
	<cfif StructKeyExists(form,"rptFlds")>
	  <cfset tmpList = form.reportFields>
	  <cfset tmpFindVal = ListFindNoCase(tmpList, form.rptFlds, ",")>
	  <cfif tmpFindVal gt 0>
	    <cfset form.reportFields = ListDeleteAt(tmpList, tmpFindVal, ",")>
	    <cfquery name="remove" datasource="#Application.dsname#">
	      <!---UPDATE #session.lbxformattable# SET at_report=0 WHERE layout='AP'--->
	          UPDATE #RptTableName# SET at_report=0 WHERE layout='AP'
	    </cfquery>
      </cfif>                
  	</cfif>
</cfif>
 
<cfif StructKeyExists(form,"moveaction") AND form.moveaction EQ "removeall">
  <cfset form.reportFields = "">
  <cfquery name="removeAll" datasource="#Application.dsname#">
    <!---UPDATE #session.lbxformattable# SET at_report=0 WHERE layout='AP'--->
        UPDATE #RptTableName# SET at_report=0 WHERE layout='AP'
  </cfquery>
</cfif>
 
<cfif StructKeyExists(form,"moveaction") AND ListFind("add,addall,remove,removeall",form.moveaction)>
 
  <cfset lcv = 0>
  <cfloop index="fldName" list="#form.reportFields#">
      <cfset lcv = lcv + 1>
      <cfquery name="addRptFields" datasource="#application.dsname#">
      UPDATE #RptTableName# SET at_report=#lcv# 
	  WHERE fld_name='#fldName#' AND layout='AP'
      </cfquery>
  </cfloop>
</cfif>
 
<cfif StructKeyExists(form,"moveaction") and form.moveaction EQ "finish">
  <cfif StructKeyExists(form,"reportFields") AND ListLen(Trim(form.reportFields))>
    <cfset tmpUrl = "custRpt.cfm?errMsg=Custom%20report%20updated">
  <cfelse>
    <cfset tmpUrl = "custRpt.cfm?errMsg=Unable%20to%20update%20custom%20report">
  </cfif>
  <cflocation url="#tmpUrl#" addtoken="false" />
<cfelse>
  <cfinclude template="intra-main2.cfm">
 
  <cfquery name="getMaxFields" datasource="#Application.dsname#">
    <!---SELECT fld_name, layout, can_search FROM #session.lbxformattable# WHERE layout='AP' AND can_search=1--->
        SELECT fld_name, layout, can_search FROM #RptTableName# WHERE layout='AP' AND can_search=1
  </cfquery>
 
  <cfquery name="getFields" datasource="#application.dsname#">
    <!---SELECT * FROM #session.lbxformattable# WHERE layout='AP' and can_search=1 AND at_report=0 ORDER BY fld_name--->
        SELECT * FROM #RptTableName# WHERE layout='AP' and can_search=1 AND at_report=0 ORDER BY fld_name
  </cfquery>
 
  <cfquery name="getRptFields" datasource="#application.dsname#">
    <!---SELECT * FROM #session.lbxformattable# WHERE layout='AP' and at_report>0 ORDER BY at_report--->
        SELECT * FROM #RptTableName# WHERE layout='AP' and at_report>0 ORDER BY at_report
  </cfquery>
 
  <p><br></p>
  <cfif StructKeyExists(URL,"errMsg") AND Len(Trim(URL.errMsg))>
    <p><div align="center"><font color="#Application.emphtext#"><b><cfoutput>#URL.errMsg#</cfoutput></b></font></div></p>
  </cfif>
  <p><br></p>
 
  <CFSET tmpReportFields = #ValueList(getRptFields.fld_name)#>
 
  <table style="border:1px solid #d1cdc6; margin-left:10px;">
    <form name="Form1" method="post" action="custRpt.cfm">
      <input type="hidden" name="reportFields" value="<cfoutput>#tmpReportFields#</cfoutput>">
	  <input type="hidden" name="moveaction" value="none" />
      <tr>
        <td><font size="-2"><b>Available Fields:</b></font></td>
        <td>&nbsp;</td>
        <td><font size="-2"><b>Selected Fields:</b></font></td>
      </tr>
      <tr>
        <td valign="top" bordercolor="#d1cdc6">
          <select name="flds" size="<cfoutput>#getMaxFields.RecordCount#</cfoutput>">
            <cfif getFields.RecordCount is 0>
              <option value="">-- All Selected --</option>
            <cfelse>
              <cfoutput query="getFields">
                <option value="#getFields.fld_name#">#getFields.fld_head1#&nbsp;#getFields.fld_head2#</option>
              </cfoutput>
            </cfif>
          </select>
        </td>
        <td valign="top">
          <p><input type="submit" class="red10" name="add" value="      >     "></p>
          <a href="#" onclick="custRpt('add')" class="red10">
			Add&nbsp;<img src="images/double_arrow.gif" border="0">
		  </a>             
          <p><input type="submit" class="red10" name="addAll" value="    >>    "></p>
          <a href="#" onclick="custRpt('addall')" class="red10">
			Add All&nbsp;<img src="images/double_arrow.gif" border="0">
		  </a>         
          <p><input type="submit" class="red10" name="remove" value="     <      "></p>
	      <a href="#" onclick="custRpt('remove')" class="red10">
		      <img src="images/double_arrow1_left.gif" border="0">&nbsp;Remove
		  </a>                
          <p><input type="submit" class="red10" name="removeall" value="    <<    "></p>
          <a href="#" onclick="custRpt('removeall')" class="red10">
			<img src="images/double_arrow1_left.gif" border="0">&nbsp;Remove all
		  </a>               
        </td>
        <td valign="top" bordercolor="#d1cdc6">
          <select name="rptFlds" size="<cfoutput>#getMaxFields.RecordCount#</cfoutput>">
            <cfif getRptFields.RecordCount is 0>
              <option value="">-- None Selected --</option>
            <cfelse>
              <cfoutput query="getRptFields">
                <option value="#getRptFields.fld_name#">#getRptFields.fld_head1#&nbsp;#getRptFields.fld_head2#</option>
              </cfoutput>
            </cfif>
          </select>
        </td>
      </tr>
    </form>
  </table>
  <p><br /></p>
  <cfinclude template="footer.cfm">
</cfif>

Open in new window

0
 
Mr_NilCommented:
Looking at your code I can't see your custRpt() function defined anywhere.  Should this function be in this file?  If not, please could you supply the function code? If it is, then you should add this function to the file and retry your links/buttons.

What are you click in on when you get no response?  The "add all" button or the "add"+double arrow image?

There are somethings you also need to be aware of:

The coldfusion code you have there could do with some TLC.
For example.
<cfset #pageTitle# = "Administration"> only needs to be <cfset pageTitle = "Administration">
<cfif #comparefmt.RecordCount# gt 0> should be <cfif comparefmt.RecordCount gt 0>
<cfset tmpReportFields = #ValueList(getRptFields.fld_name)#> should be <cfset tmpReportFields = ValueList(getRptFields.fld_name) />

Also, ParameterExists is a deprecated coldfusion function and should be replaced with IsDefined() or StructKeyExists() eg. ParameterExists(form.finished) should be isDefined("form.finished") or StructKeyExists(form,"finished") depending on which version of CF Server you're working with. (Can't recommend using CF8 strongly enough)

0
 
CashmgmtAuthor Commented:
I copied the Custrpt function when I described my issue.  the function is in another file I include in this one, that's why it's not in the code I pasted.  when I click on remove, remove all, add, or add all, nothing happens.  It submits cause the page refreshes, but the fields that I select do not move to the other table.  I still have the original submit buttons in the code which work fine.  i need to replace those with a link instead.  Here's the function:
       function custRpt()
            {
              document.Form1.action = 'custRpt.cfm';
              document.Form1.submit();
            }
0
 
Mr_NilCommented:
OK - Cool - just needed to check it wasn't supposed to be in that cf page.

The reason that nothing is happening is because the code is looking for the press of the button to act upon.
When you click on the "Add All" button it creates a variable called "addall" in the form scope. Take a look at line 83 in your above code.  You'll see <cfif ParameterExists(form.addall) ....>

What you'll need to do is recreate this with your javascript function.  What I would recommend is creating a hidden field called something like "moveaction".  On your link pass through the action that is being taken to your function eg. <a href="javascript:custRpt('addall')" ...>

In your function set the hidden field you created to this value:

       function custRpt(moveaction)
            {
              document.Form1.moveaction.value = moveaction;
              document.Form1.action = 'custRpt.cfm';
              document.Form1.submit();
            }

What you'll need to do with the cf code is change all the references to form.add or form.addall etc. to be form.moveaction EQ "add" or form.moveaction EQ "addall" as appropriate. eg. line 83 would look like this:
<cfif StructKeyExists(form,"moveaction") AND form.moveaction EQ "addall">

Hope that makes sense and helps.
0
 
CashmgmtAuthor Commented:
Thanks for your help! I was able to get it working using your sample code.
0
All Courses

From novice to tech pro — start learning today.