Skip to main content
Inspiring
December 2, 2009
Question

Set session var using js

  • December 2, 2009
  • 3 replies
  • 846 views

Hi all, I have small js that is being called when a radio button is clicked. I need that to set a cf session var which will have the radio value so that when the page refresh it will remember what is selected...

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<cfif cgi.PATH_TRANSLATED CONTAINS 'index.cfm'>
  <cfoutput>
   <META HTTP-EQUIV="refresh" content="60;URL=http://#HTTP_HOST#/NEA/index.cfm?location=ALL">
  </cfoutput>
</cfif>

         <script type="text/javascript">
         function select_location(select_me){
          window.location ="index.cfm?location=" + select_me.value;
         }
         </script>
         <input  <cfif url.location eq "NM">checked="checked"</cfif> type="radio" name="location" id="NM" value="NM" onClick="select_location(this);"><label for="NM">NM</label> 
         <input  <cfif url.location eq "SM">checked="checked"</cfif> type="radio" name="location" id="SM" value="SM" onClick="select_location(this);"><label for="SM">SM</label> 
         <input <cfif url.location eq "BQ">checked="checked"</cfif> type="radio" name="location" id="BQ" value="BQ" onClick="select_location(this);"><label for="BQ">BQ</label> 
         <input <cfif url.location eq "MV">checked="checked"</cfif> type="radio" name="location" id="MV" value="MV" onClick="select_location(this);"><label for="MV">MV</label> 
         <input <cfif url.location eq "SI">checked="checked"</cfif> type="radio" name="location" id="SI" value="SI" onClick="select_location(this);"><label for="SI">SI</label> 
         <input <cfif url.location eq "BR">checked="checked"</cfif> type="radio" name="location" id="BR" value="BR" onClick="select_location(this);"><label for="BR">BR</label> 
         <input <cfif url.location eq "HV">checked="checked"</cfif>  type="radio" name="location" id="HV" value="HV" onClick="select_location(this);"><label for="HV">HV</label>
         <input <cfif url.location eq "ALL">checked="checked"</cfif> type="radio" name="location" id="ALL" value="ALL" onClick="select_location(this);"><label for="ALL">ALL</label><br>

This topic has been closed for replies.

3 replies

BKBK
Community Expert
Community Expert
December 3, 2009
Set session var using js

Yes, it is possible to use Javascript to navigate to a page in which session variables are set. There.

emmim44Author
Inspiring
December 3, 2009

I will have to check some samples...if u have one handy, pls feeel free

BKBK
Community Expert
Community Expert
December 3, 2009

You didn't ask any question. Are you double, Emmim44?

ilssac
Inspiring
December 2, 2009

JavaScript runs on the Client.  ColdFusion runs on the server.  They do not talk to each other or share memory.

The only way to get data from the client to the server is to make a request.  The only way to get data from the server to the client is to respond to a request.

You can make that request by submitting a form either in the get or post scope.

You can make that request by sumitting a request with the xmlHTTPrequest() function, commonly called AJAX.

But somehow or the other you have to make a request.