12 Replies Latest reply on Feb 20, 2014 12:25 PM by iccsi

    <cfif IsDefined("form.MySelect")

    iccsi Level 1

      I want to to pass the value users select from form.MySelect.

      I use

       

      <cfif IsDefined("form.MySelect")

      </cfif>

       

      it seems that ColdFusion server does not recognize it.

      It works if I use text control.

       

      I would like to know are there anyway to pass select value to ColdFsuion server to use <CFIF IsDefined>

      If not, any suggestions or use hidden controls to set the value when user select a value from drop down box.

       

      Your help and information is great appreciated,

       

      Regards,

       

      Iccsi,

        • 1. Re: <cfif IsDefined("form.MySelect")
          BKBK Adobe Community Professional & MVP

          Coldfusion does recognize it. Use the value of the name attribute of the select field. For example,

           

          <cfif isDefined("form.mySelect")>

          form.mySelect: <cfoutput>#form.mySelect#</cfoutput>

          </cfif>

           

          <cfform action="#cgi.SCRIPT_NAME#">

          <cfselect name="mySelect">

          <option value="1">Yes</option>

          <option value="0">No</option>

          </cfselect>

          <cfinput name="sbmt" type="submit" value="send">

          </cfform>

          • 2. Re: <cfif IsDefined("form.MySelect")
            iccsi Level 1

            I use cfselect like following code,

            "hello" shows when I use <cfif not isDefined>, it does not show isDefined,

             

            Thanks again,

             

            Regards,

             

            <cfif isDefined("form.lstMylst")>

             

                hello

             

            </cfif>

             

             

            <td>
              <cfselect name="lstMylst" id="lstMylst">

                     <cfoutput query="myQuery">
                     <option value="#MyQuery.MyID#"
                        <cfif (isDefined("form.MyID") AND form.MyID EQ myQuery.MyID)>selected="selected"</cfif>> #MyQuery.MyName# </option>
                        
                     </cfoutput>

              </cfselect>

            </td>

            • 3. Re: <cfif IsDefined("form.MySelect")
              BKBK Adobe Community Professional & MVP

              The form is probably not submitted, is submitted to a different action page or has method type 'get'. To test, temporarily replace

               

              <cfif isDefined("form.lstMylst")>

                  hello

              </cfif>

               

              with 

               

              <cfif isDefined("url.lstMylst")>

                  hello

              </cfif>

              <cfdump var="#url#" label="URL scope">

              <cfdump var="#form#" label="Form scope">

               

              Do you see 'hello'? Are the URL or form variables dumped?

              • 4. Re: <cfif IsDefined("form.MySelect")
                iccsi Level 1

                I see variable dump, but not hello,

                It submitted, but  I only see the variable I assigned or text controls, no select control.

                 

                Regards,

                 

                Iccsi,

                • 5. Re: <cfif IsDefined("form.MySelect")
                  iccsi Level 1

                  I think I know why,

                  I use jQuery and have the following code on submit button, because I use my won stored procedures to update my database.

                   

                   

                  event.preventDefault();

                   

                  Because above code on submit, it does not use default submit.

                  Are there any work around for this?

                  Thanks again for helping and information,

                   

                  Regards,

                   

                  Iccsi,

                  • 6. Re: <cfif IsDefined("form.MySelect")
                    iccsi Level 1

                    I think that the solution would be have 1 jQuery on my submit on click event.

                    The first one to update my tables in the database and second one to check if mylst exists then do the hello things in another cfm file. could be a solution.

                     

                    Thanks again for helping and information,

                     

                    Regards,

                     

                    Iccsi,

                    • 7. Re: <cfif IsDefined("form.MySelect")
                      BKBK Adobe Community Professional & MVP

                      It is possible that the select field is excluded from the form submission. Could we see the code?

                      • 8. Re: <cfif IsDefined("form.MySelect")
                        iccsi Level 1

                        the whole cfm file code is too long, which part of code you want to see?

                        onSubmit from jQuery?

                         

                        Regards,

                         

                        Iccsi,

                        • 9. Re: <cfif IsDefined("form.MySelect")
                          iccsi Level 1

                          here is html code:

                           

                          <input name="cmdSubmit" type="submit" id="ccdSubmit" value="CONFIRMAR"/>

                           

                          here are my on submit code ,

                          I still do not see the select even I comment event.preventDefault,

                           

                           

                          jQuery("#cmdSubmit").click(function(event) {

                                    

                           

                            

                            <!---  event.preventDefault();--->

                             

                             if (validate())

                             {

                            

                              if (document.MyForm.MyNumber.value.length == 0)

                               {

                             document.MyForm.MyNumber.value =

                                document.getElementById('MyForm').hidNumber.value;

                               }

                             

                            

                            

                              jQuery.ajax({

                               url:  "/Mycfm.cfc?method=MyMethod&MyNumber="   ("#txtMyNumber").val()),

                            

                            

                               type: "POST",

                               success: function(data)

                               {

                              

                                alert( "My Number " + GetMyNumber(jQuery("#txtMyNumber").val()) +

                                " for " + GetMyNumber(jQuery("#MyName").val()) +

                                 " Data update completed");

                              

                               

                               }

                              });

                             }

                             

                            });

                          • 10. Re: <cfif IsDefined("form.MySelect")
                            iccsi Level 1

                            I think that I know whewre the issue is which is event.preventDefault.

                            I had it works when I comment out the event.preventDefault.

                             

                            Since I use jQuery onSubmit to hadndle submit, I tihnk the only solution would be have another jQuery to handle my second task to check lstMylst.

                             

                            Please advise if there is another better solutiuon for this?

                            Your help and information is great appreciated,

                             

                            Regards,

                             

                            Iccsi,

                            • 11. Re: <cfif IsDefined("form.MySelect")
                              BKBK Adobe Community Professional & MVP

                                <!---  event.preventDefault();--->

                              Shouldn't that be /* event.preventDefault(); */ ? Anyway, from what I have read about event.preventDefault(), its purpose is to prevent the default click-action which, in this case, is form submission. So it is actually doing what it is designed to do! Why don't you comment it out?

                              • 12. Re: <cfif IsDefined("form.MySelect")
                                iccsi Level 1

                                Yes, thanks for helping,

                                I think I had to do this for my jQuery update,

                                After removing the code, it works and it seems that it does not break other functions,

                                Thanks again for helping and information,

                                 

                                Regards,

                                 

                                Iccsi,