Link to home
Start Free TrialLog in
Avatar of Waterstone
Waterstone

asked on

CFinput, use the onclick method to do a cfset of a CF variable


I have this cfinput statement in a table so that I get as many rows as there are records in my query result.

<cfinput type="radio" name="SelectedDepartment" value= "#CountDepartmentStatus.DepartmentCode#" >

I would like to add the onclick option to it and  have the javascript routine do the following cfset.

<cfset client.DepartmentCode=CountDepartmentStatus.DepartmentCode>

Is there a way to execute a cfset from the onclick method of a cfinput?

Thanks,
WS
Avatar of Tacobell777
Tacobell777

You can only call CF via JavaScript if you would call another document.

What is it exactly that you want to do?

Do you want to pass the selected option back to CF?

<form method="post" action="somefile.cfm">
<cfinput type="radio" name="SelectedDepartment" value= "#CountDepartmentStatus.DepartmentCode#" >
<input type="submit" value="submit">
</form>

Then in somefile.cfm you will have

<cfset client.DepartmentCode=form.SelectedDepartment>
Avatar of Waterstone

ASKER



I was hoping to set the cf variable without leaving the document.
Hi WS,

What are you wanting to do once the value is set?  Go to the results page?  Let the user make other selections, then hit a button for the results?

Tell us what you are wanting to accomplish and we can explain the best approach.

Take Care,

Seth
You can only do that if you use hidden frames or Iframes....


Good Morning,

I'd like to set the value and reset the value as desired, then allow the user to select from the navbar menu to go to a number of different pages.

The navbar contains graphics as menu items that are consistent with the rest of the site. Forms restrict me to a standard button look that violates the design of the site.

Never used hidden frames or I frames.

WS
ASKER CERTIFIED SOLUTION
Avatar of Seth_Bienek
Seth_Bienek

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial


Seth,

It looks like cookies will be the best solution for this problem.  Do you know of any examples of using cfcookie to read a cookie?

Thanks,
Stece
Cookies are not the best solution, for variables that you want to store CLIENT. is the best storage, as it is on your side. The cookie should only store cfid and cftoken which reveals nothing important.

But good luck anyway.
I agree that cookies are not ideal, but they allow me to pass a simple variable to the next form no matter what that form is.  It's a solution for a small percentage of the users and the value get's passed to a Client variable as soon as that next form loads.  If there was a way to do a cfset from a radio button it would be ideal, but I'll have to settle for less-than-ideal but functional, unless you know of a better way.

Thanks again for you input.

WS
The way you are setting a cookie will be the same as I suggested to set a client variable.
You should use client variables for settings you like to store for a long period of time ( but not permenant) you should use session variables for variables that exists only throughout the users session.


Well, it doesn't seem to be the same to me because setting the client variable seems to require that I use the form's submit button to call the other form.  Is this accurate or am I missing something?