Advertisement

10.22.2007 at 01:06PM PDT, ID: 22910081
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

insert /update problem in coldfusion

Asked by erikTsomik in ColdFusion Application Server, Cold Fusion Markup Language

Tags: , , ,

In my form I have 2 options insert or update. When I do the update it actually insert the record
<cffunction name="programsAction" hint="Add/Edit programs">

      <cfsavecontent variable="output">

    <cfoutput>

          <script type="text/javascript" src="/spry/includes/xpath.js"></script>
    <script type="text/javascript" src="/spry/includes/SpryData.js"></script>
    <script type="text/javascript" src="/spry/includes/SpryNestedXMLDataSet.js"></script>
    <script type="text/javascript" src="/spry/widgets/accordion/SpryAccordion.js"></script>
    <link href="/spry/widgets/collapsiblepanel/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="/spry/includes/Effect.js"></script>
    <script type="text/javascript" src="/spry/widgets/collapsiblepanel/SpryCollapsiblePanel.js"></script>
    <link href="/spry/widgets/accordion/SpryAccordion.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/spry/includes/tmt_core.js"></script>
    <script type="text/javascript" src="/spry/includes/tmt_net.js"></script>
    <script type="text/javascript" src="/spry/includes/tmt_form.js"></script>
    <script type="text/javascript" src="/spry/includes/tmt_ajaxform.js"></script>
    <script language="JavaScript" type="text/javascript" src="/spry/widgets/tabbedpanels/SpryTabbedPanels.js"></script>
    <link href="/spry/widgets/tabbedpanels/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
 <script type="text/javascript">
            var dsProducts2 = new Spry.Data.XMLDataSet("program.cfm","programs/program",{ useCache: false});
            
            var dsProductFeatures = new Spry.Data.NestedXMLDataSet(dsProducts2, "features/feature");
            
            </script>
    <script type="text/javascript" >
function dsRefresh2(){
    dsProducts2.loadData();
      
}

function getcurrentvalue(){
var current = document.getElementById("programlist").value;
if (dsProducts2.getDataWasLoaded()){
      
      var data = dsProducts2.findRowsWithColumnValues({'id': current}, true);
      

            if (data){

                        document.getElementById("updateProgram").style.display='block';
                        document.getElementById("insertprogram").style.display='none';
                  document.getElementById("program2").value = data.program;
                  document.getElementById("Degree2").value = data.degree;
                  document.getElementById("Major2").value = data.major;
                  document.getElementById("fullname2").value = data.fullname;
                  document.getElementById("programoption2").value = data.programoption;
                  document.getElementById("fee1").value = data.fee;
                  document.getElementById("hiddenfield2").ckecked = data.hidden;
                  document.getElementById("programnote2").value = data.programnote;
                  document.getElementById("cohortname2").value = data.cohortname;
                  
            
                  
                          }

                              }
                        

                              }

window.onload=function Load () {
      document.getElementById("updateProgram").style.display='none';
      


}

function LoadShow (){
document.getElementById("insertprogram").style.display='block';
document.getElementById("saveprogram").style.display='none';
document.getElementById("updateProgram").style.display='block';
document.getElementById("program2").value = "";
document.getElementById("Degree2").value = "";
document.getElementById("Major2").value = "";
document.getElementById("fullname2").value = "";
document.getElementById("programoption2").value = "";
document.getElementById("fee1").value = "";
document.getElementById("hiddenfield2").value.ckecked = false;
document.getElementById("programnote2").value = "";
document.getElementById("cohortname2").value = "";
            

}
</script>



 <div id="programSection">
<cfparam name="form.school" default="">
    <cfset session.schoolcode=form.school>
     
     <cfif session.schoolcode eq "psl">
                  <h2>Program Section: Select Your Program</h2>
            <cfelse>    
                        <h2>Program Section: Select Your Area of Interest</h2>
            </cfif>    
           
            <cfoutput><p>Thank you for choosing the #session.schoolname#.<cfif session.schoolcode eq "business"> <strong>Please note that all applications to the Carey Business School should be submitted via the Web using the online application. Paper applications are no longer accepted.</strong></cfif> The information and steps that follow should help you easily navigate the online admissions process. If you have additional questions, please don't hesitate to contact us at #session.appphonenumber# or email <a href="mailto:#session.appemail#">#session.appemail#</a></p>.</cfoutput>
                  <form action="insertcategory.cfm" method="post" tmt:ajaxform="true" tmt:ajaxformcallback="dsRefresh2" name="program" >
<cfoutput>         <input type="hidden" value="#session.schoolcode#" name="school"></cfoutput>

           <div class="TabbedPanels" id="tp1">
  <ul class="TabbedPanelsTabGroup">
    <li class="TabbedPanelsTab" tabindex="0">Programs</li>
    <li class="TabbedPanelsTab" tabindex="0">Assign Requirements to the program</li>
    <li class="TabbedPanelsTab" tabindex="0">Locations</li>
    <li class="TabbedPanelsTab" tabindex="0">Tab 4</li>
  </ul>
  <div class="TabbedPanelsContentGroup">
     <div class="TabbedPanelsContent"> <div id="programSection">
                 
     <div spry:region="dsProducts2" id="content">
      <select spry:repeatchildren="dsProducts2" spry:setrow="dsProducts2" name="programlist" id="programlist" size="15" multiple="true" onchange="getcurrentvalue();">
      <option spry:if="{ds_RowNumber} == {ds_CurrentRowNumber}"  spry:select="rowSelected" value="{id}" >{webname}</option>
       <option spry:if="{ds_RowNumber} != {ds_CurrentRowNumber}" spry:select="rowSelected"  value="{id}">{webname}</option>
        </select>
        <div id="showAddProgram" onClick="LoadShow ()">[Add Program] </div>
      <div id="updateProgram">
              
                   <!---Program--->
                 
              <div id="program">
                  <label id="label" for="program2">Program:</label>
           <span class="program1"><input type="text" id="program2" name="program2"></span>
               
           </div>
           
            <!---Degree--->
         <div id="Degree">
                  <label id="label" for="Degree">Degree:</label>
             <span class="degree1"><input type="text" id="Degree2" name="Degree2"></span>
             </div>
           
       
           
            <!---Major--->
           
             <div id="Major">
                  <label id="label" for="Major">Major:</label>
             <span class="major1"><input type="text" id="Major2" name="Major2"></span>
             
           
            </div>
           
            <!---Full Name--->
            <div id="fullname">
                  <label id="label" for="fullname">Full Name:</label>
                <span class="fullname1"><input type="text" id="fullname2" name="fullname2"></span>
               
            </div>
           
            <!---Program Option--->
            <div id="programoption">
                  <label id="label" for="programoption">Program Option:</label>
             <span class="programoption1">   <input type="text" id="programoption2" name="programoption2"></span>
             
           
            </div>
           
            <!---fee--->
           
         <div id="fee">
                  <label id="label" for="fee">Fee:</label>
                <span class="fee2"><input type="text" id="fee1" name="fee1"></span>
               
           
            </div>
           
           
           
            <!---Hidden field--->
           
             <div id="hiddenfield">
                  <label id="label" for="hiddenfield">Show/Hide:</label>
                <label for="hiddenfield">Yes</label>
               
                <span class="hiddenfield1"><input type="radio" id="hiddenfield2" name="hiddenfield" value="0" >
                 <label for="hiddenfield">No</label>
                <input type="radio" id="hiddenfield2" name="hiddenfield" value="1" checked></span>
             
                
           
            </div>

            <!---Program Note--->
           
             <div id="programnote">
                  <label id="label" for="programnote">Program Note:</label>
               <span class="programnote1"> <input type="text" id="programnote2" name="programnote2"></span>
             
            </div>
           
            <!---cohort name--->
           
             <div id="cohortname">
                  <label id="label" for="cohortname">Cohort Note:</label>
                <span class="cohortname1"><input type="text" id="cohortname2" name="cohortname2"></span>
               
            </div>
             <input type="submit" name="saveprogram" id="saveprogram" value="Update Program">
             <input type="submit" name="insertprogram" id="insertprogram" value="Insert Program">
</div>
       
       </div>
       

     </div>  </div>
     <div class="TabbedPanelsContent"> Tab 2 Content </div>
     <div class="TabbedPanelsContent">Tab 3 Content </div>
     <div class="TabbedPanelsContent"> Tab 4 Content</div>
  </div>
  </div>
  </div>
  </div>
  </form>
  <cfoutput><cfdump var="#form#"></cfoutput>
  <script language="JavaScript" type="text/javascript">
var tp1 = new Spry.Widget.TabbedPanels("tp1", { defaultTab: 0 });

</script>

 
</div>




</cfoutput>
</cfsavecontent>
<cfreturn output>
</cffunction>
   

And the processing page her
<cfif NOT StructIsEmpty(form)>
<cfcontent type="text/xml; charset=UTF-8" reset="Yes" />
<cfparam name="form.program2" default="">
    <cfparam name="form.Degree2" default="">
    <cfparam name="form.Major2" default="">
    <cfparam name="form.fullname2" default="">
    <cfparam name="form.programoption2" default="">
    <cfparam name="form.fee1" default="">
    <cfparam name="form.hiddenfield" default="">
    <cfparam name="form.programnote2" default="">
    <cfparam name="form.cohortname2" default="">
<cfif isDefined("insertprogram")>

        <cftry>
        <cfquery name="insertProgram" datasource="HotBanana_Manager">
       
        insert into trnAcademicPrograms (program,degree,major,fullname,programoption,fee,school_division,hidden,programNote,cohortname) values
('#form.program2#','#form.degree2#','#form.major2#','#form.fullname2#','#form.programoption2#',#form.fee1#,'#session.schoolcode#', '#form.hiddenfield#', '#form.programnote2#', '#form.cohortname2#')

        </cfquery>
   <cfcatch type="database">
   There was a dataabse error
   </cfcatch>
   </cftry>
   <cfelse>
   <cfabort>
</cfif>




 
<cfif isDefined("saveprogram")>
<cfparam name="form.program2" default="">
    <cfparam name="form.Degree2" default="">
    <cfparam name="form.Major2" default="">
    <cfparam name="form.fullname2" default="">
    <cfparam name="form.programoption2" default="">
    <cfparam name="form.fee1" default="">
    <cfparam name="form.hiddenfield" default="">
    <cfparam name="form.programnote2" default="">
    <cfparam name="form.cohortname2" default="">

    <cfparam name="form.programlist" default="">
        <cftry>
       <cfquery name="update" datasource="HotBanana_Manager">
              update trnAcademicPrograms set program='#form.program2#', degree='#form.degree2#', major='#form.major2#', fullname='#form.fullname2#', programoption='#form.programoption2#', fee=#form.fee1#,
hidden=#form.hiddenfield#, programnote='#form.programnote2#', cohortname='#form.cohortname2#' where school_division='#session.schoolcode#' and id=#form.programlist#
       
        </cfquery>
   <cfcatch type="database">
   There was a dataabse error
   </cfcatch>
   </cftry>
       <cfelse>
       <cfabort>
</cfif>


</cfif>


Start Free Trial
[+][-]10.23.2007 at 07:50PM PDT, ID: 20136038

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: ColdFusion Application Server, Cold Fusion Markup Language
Tags: coldfusion, insert, radio, update
Sign Up Now!
Solution Provided By: mmc98dl1
Participating Experts: 2
Solution Grade: A
 
 
[+][-]10.24.2007 at 06:46AM PDT, ID: 20138806

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.24.2007 at 07:14AM PDT, ID: 20139143

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.24.2007 at 07:23AM PDT, ID: 20139229

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.24.2007 at 07:35AM PDT, ID: 20139311

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628