4 Replies Latest reply on Mar 16, 2007 5:48 PM by balote

    selection box not working

    balote Level 1
      i was asked to edit some code

      one of the selection boxes wasnt working and was not updating the db at all

      here is the code snippet

      <!--- the CFC code being called
      this basically puts together the values which are valid for display in the selection box
      then returns it to the invoker
      --->

      <CFFunction name = "Sel_SpecifiedDateFlag" output = "false" returntype = "string" access = "public">
      <!--- 引数の定義 --->
      <CFArgument name = "prm_SelID" required = "true">

      <CFSet res1 = "">
      <!--- コンボリストのID設定(一元管理)--->
      <cfset id = 8>

      <CFQuery name = "query1" datasource = "#APP_DB_DSN#">
      select code , COALESCE(code::text,'') || ':' || COALESCE(name,'') as name
      from tblpmdsetcomblist
      where valid_flag = 1
      and id = #id#
      order by sort,code
      </CFQuery>

      <CFQuery name = "query2" datasource = "#APP_DB_DSN#">
      select code from tblpmdsetcomblist
      where valid_flag = 1
      and id = #id#
      and default_flag = 1
      </CFQuery>

      <!--- 念のため、デフォルト確認 --->
      <CFIf query2.RecordCount NEQ 1>
      <CFReturn "<font color='red'><strong>リストテーブルデフォルトエラー</strong></font>">
      </CFIf>

      <!--- prm_SelIDがNullの時のデフォルトを設定 --->
      <CFIf prm_SelID eq "">
      <CFSet prm_SelID = #query2.code#>
      </CFIf>


      <CFLoop Query="query1">
      <CFSet res1 = res1 & "<OPTION Value='#code#'">
      <CFIf Compare(code , prm_SelID) eq 0>
      <CFSet res1 = res1 & " SELECTED">
      </CfIf>
      <CFSet res1 = res1 & ">">
      <CFSet res1 = res1 & #name#>
      <CFSet res1 = res1 & "</OPTION>#chr(10)#">
      </CFLoop>

      <CFReturn res1>
      </CfFunction>

      <!--- this is the code that invokes the CFC code above and displays it as well
      --->

      <CFInvoke Component="component.selbox" Method="Sel_Plusoneflag" ReturnVariable="getstr">
      <CFInvokeArgument name="prm_SelID" Value="#plus_one_flag#">
      </CFInvoke>

      <select name="plus_one_flag" Size=1>
      <CFOutput>#getstr#</CFOutput>
      </select>



      <!--- this is what #getstr# looks like when viewed via page source viewer
      --->
      <select name="plus_one_flag" Size=1>
      <OPTION Value='0' SELECTED>0:プラフワン不可</OPTION>
      <OPTION Value='1'>1:プワスワン可</OPTION>

      </select>

      i checked all the sources of the problem which are obvious to me but found none :(

      btw the ascii characters in the code are japanese characters if youre not seeing them properly

        • 1. Re: selection box not working
          Level 7
          in the code you posted there is no code for updating the db...
          plus:

          >
          > <CFQuery name = "query1" datasource = "#APP_DB_DSN#">
          > select code , COALESCE(code::text,'') || ':' || COALESCE(name,'') as name
          > from tblpmdsetcomblist
          > where valid_flag = 1
          > and id = #id#
          > order by sort,code
          > </CFQuery>

          there is no 'sort' column pulled from the db or aliased by that name as
          it appears in the order by clause in the query above...


          > <!--- this is the code that invokes the CFC code above and displays it as well
          > --->
          >
          > <CFInvoke Component="component.selbox" Method="Sel_Plusoneflag"
          > ReturnVariable="getstr">

          you did not post any code for the 'Sel_Plusoneflag' function in your
          cfc... did you post a wrong function or should you change the method's
          name in the cfinvoke?

          >
          > i checked all the sources of the problem which are obvious to me but found
          > none :(

          and what's the actual problem you are facing? the select box still not
          working (HOW is it not working? - not displaying/displaying wrong data?)
          or something else?

          --

          Azadi Saryev
          Sabai-dee.com
          http://www.sabai-dee.com
          • 2. Re: selection box not working
            balote Level 1
            i posted the wrong code, here is the correct one

            <CFFunction name = "Sel_Plusoneflag" output = "false" returntype = "string" access = "public">
            <!--- 引数の定義 --->
            <CFArgument name = "prm_SelID" required = "true">

            <CFSet res1 = "">
            <!--- コンボリストのID設定(一元管理)--->
            <cfset id = 6>

            its all the same from that point on

            the problem with the selection box is when you choose an option (only two; 0 or 1) then submit it, it doesnt show up in the database, a new record is placed but the plus_one_flag field is null
            • 3. Re: selection box not working
              Level 7
              OK. can you also please post the code that inserts/updates record in the
              db? since your select box displays on the page, then the problem must be
              in the update/insert code...

              --
              Azadi Saryev
              Sabai-dee.com
              Vientiane, Laos
              http://www.sabai-dee.com
              • 4. Re: selection box not working
                balote Level 1
                thanks again sir, ive found the problem in the template that submits all the data to the db, i was looking at the wrong place after all.

                its all working good now :)