set a session variable

I have the form where I want to assign an id as a step selected. from the drop down I select the course of action . All entry from drop down should have an id of which determine th enext step  and based upon selection I need to enable session variables for example if the business is selected it will generate the id 2 and set the session variable = and so on
function validateForm(objForm){
      var strErr='';
            strErr='Invalid Selection!\nUnable to submit form.\nPlease make a valid selection and try again.'

return !strErr;


function setSession (obj){

      if (obj.value=='business'){
            <cfoutput><cfset session.schoolcode='business'>
            <cfset step=2></cfoutput>

if (obj.value=='education'){
            <cfoutput><cfset session.schoolcode='education'><cfset step=2></cfoutput>

if (obj.value=='psl'){
            <cfoutput><cfset session.schoolcode='psl'><cfset step=2></cfoutput>

    <cfparam name="" default="">
    <div id="menuOption">
    <h2 style="margin:20px;">Please select a desired school:</h2>
  <form action="" method="post" enctype="multipart/form-data" onSubmit="return validateForm(this)" onclick="setSession (this);">
             <select name="school" id="school">
<!---<option>Please select a school</option>
<option value="2">Business</option>
<option value="2">Education</option>
<option value="2">PSL</option>--->
<option>[Please select a school]</option>
<cfoutput query="school">
<option value="#school_division#">#school_division#</option>
                <input type="submit" value="Select School" id="btnsubmit" >
LVL 19
erikTsomikSystem Architect, CF programmer Asked:
Who is Participating?
I'm confused by the ColdFusion code wrapped in JS Logic code? The JS logic will not fire off this coldfusion code it will ALL be run at render time...

Also, you don't need to wrap all your code in cfoutputs...

You will want to modify form inputs and submit the form to the next page using 100% JS... If you still need something set into the session scope, that is where you will do it (on page 2).
erikTsomikSystem Architect, CF programmer Author Commented:
I want to set the session variable once i clik on submit
You won't be able to do that on that page...

You will have to do it on the page you submit to...

<cfset session.schoolcode = form.schoolcode>
erikTsomikSystem Architect, CF programmer Author Commented:
That works. All i had to do is to put it in the different function. By the chance do you know how to work with the tabbed panels in Spry
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.