Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Passing record id during onClick while also submitting the form

Participant ,
Jul 24, 2009 Jul 24, 2009

I'm displaying data in two different tables. All of the data is static except for a status field which is also the field that determines what table the data is displayed in. Inside of form tags I am using a cfoutput tag to loop through the records for each table. The status record is in a cfinput with a type of radio button to set the status. I can submit the form using the onClick event of the radio button but I'm unsure how to pass the record id of the record that will need the status field to be updated on my action page. Is it possible to pass this record id along using javascript and then read that it on the action page to pass along to my sql? I planned to send the form back to the same page so that toggling the radio button would move the record to the other table. I wanted to avoid using a submit button and have the change in values of the status field move the record to the "closed" status table or vice versa.

875
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Aug 21, 2009 Aug 21, 2009

Greetings,

Have you tried adding the code below the end of your action line

?record_id=#URLEncodedFormat(record_id)#

Example:

onClick="this.form.action='path_to_page.cfm?record_id=#URLEncodedFormat(record_id)#';this.form.submit()"

If I understand what it is you are trying to do, I setup a sample and tried the above "Example" code and it

passed a record id to the designated page without any issues arising.

Leonard

Translate
Engaged ,
Aug 21, 2009 Aug 21, 2009

Greetings,

Have you tried adding the code below the end of your action line

?record_id=#URLEncodedFormat(record_id)#

Example:

onClick="this.form.action='path_to_page.cfm?record_id=#URLEncodedFormat(record_id)#';this.form.submit()"

If I understand what it is you are trying to do, I setup a sample and tried the above "Example" code and it

passed a record id to the designated page without any issues arising.

Leonard

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 21, 2009 Aug 21, 2009
LATEST

Hi Lenorad,

I ended up building my forms a different way in this situation but your answer was exactly what I was looking for at the time. I was unaware that I could pass the action url with a variable on it as part of the onClick event. Thanks for showing me this.

-John

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources