Skip to main content
Known Participant
February 10, 2012
Question

Onclick with checkboxes and add value to a string

  • February 10, 2012
  • 1 reply
  • 1637 views

Hello, I have a search results page that has a checkbox next to each returned record. Is there a way to append its value to a string via an Onclick function? My search results page uses paging as well, that is why I was wondering if it can be done as they click the checkbox.

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
February 11, 2012

Which variables hold the value of the search results? If one knows this, then answering the question will be easy.

pmlink360Author
Known Participant
February 11, 2012

The name of my form is "get_records" and the name of my checkbox is "f_selected_record".

I was using this code but I was only getting the current id of the checkboxes on the current page I was on.....so if I did a search and clicked on a checkbox on page 1 and went to page 2 clicked 2 checboxes, I would only have the 2 ids from page 2.

<cfif isdefined("form.get_records")>

    <cfloop index="i" list="#Form.f_selected_record#" delimiters=";">

        <cfoutput><cfset session.get_all_records = ListAppend(session.get_all_records,'#i#')></cfoutput>

    </cfloop>

</cfif>

BKBK
Community Expert
Community Expert
February 11, 2012

pmlink360 wrote:

The name of my form is "get_records" and the name of my checkbox is "f_selected_record".

I was using this code but I was only getting the current id of the checkboxes on the current page I was on.....so if I did a search and clicked on a checkbox on page 1 and went to page 2 clicked 2 checboxes, I would only have the 2 ids from page 2.

<cfif isdefined("form.get_records")>

    <cfloop index="i" list="#Form.f_selected_record#" delimiters=";">

        <cfoutput><cfset session.get_all_records = ListAppend(session.get_all_records,'#i#')></cfoutput>

    </cfloop>

</cfif>

If the name of your form is "get_records", then this statement is absurd: <cfif isdefined("form.get_records")>. The statement suggests that "get_records" is the name of a field in the form. Is it?

You said you have a search results page that has a checkbox next to each returned record. My question is, which variables hold the values of the returned records? Do you have 2 forms, one posting to the results page and one on the results page(in which are the checkboxes)?