I would like to able to bind a series of 3 buttons to toggle 3 boolean values on a database message entry. The boolean database entries are read|unread, actioned|pending, referral|message and the message entry has the unique key "messageID". I want the buttons to display the record starting values (which I presume is bindonload="true").
I've limped towards
<cfform>
<cfinput type="hidden" name="switchName" value="read">
<cfinput type="button" bind="cfc:cfcs.messages.toggle({toggle@click},{switchName@none})" name="toggleRead" value="Read" bindonload="true">
</cfform>
and in the cfc
<cffunction access="remote" name="toggle" output="false" returntype="any" >
<cfargument required="true" name="toggle" type="any"/>
<cfargument required="true" name="switchName" type="any"/>
<cfif toggle eq "Read">
<cfreturn "Unread">
<cfelseif toggle eq "Unread">
<cfreturn "Read">
</cfif>
</cffunction>
This gets me some of the way there, in so far as it toggles the button label, but I'm foxed on how to pick up the initial db values to display the initial status.
Also is there a way to pass other variables in the bind statement without using hidden fields and control@none format, e.g. I will need to pass in the messageID so I can update the correct record. I wouldn't have put in the switchName input if I knew how to simply pass the switchName variable in a beter way.
Many thanks for any light you can shed?