set a session variable

Posted on 2007-10-09
Last Modified: 2013-12-24
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" >
Question by:erikTsomik
    LVL 4

    Accepted Solution

    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).
    LVL 19

    Author Comment

    I want to set the session variable once i clik on submit
    LVL 4

    Expert Comment

    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>
    LVL 19

    Author Comment

    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

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Suggested Solutions

    The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
    PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now