Web Analytics Made Easy -
StatCounter ColdFusion Newbie - CodingForum

Announcement

Collapse
No announcement yet.

ColdFusion Newbie

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ColdFusion Newbie

    I'm an ASP guy who recieved a request to build a ColdFusion application. Problem: I have several buttons on a form (options). Each button will submit the form to the same page but, based upon which button has been clicked, a different query will be triggered. For some reason ColdFusion will not pass the values of the buttons to the recieving page for evaluation. Does anyone know if this is possible? Been to the CF Forums and no bites. Thanks.

  • #2
    Are using cfform of just a regular form? Can you post some code?
    does this sig match?

    Comment


    • #3
      Using standard HTML form. Since CF is new to me I'm trying to avoid using it as much as possible. Should I be using CFFORM?

      Can't post the actual code right now, still in the midst of testing but here is the basic's of what I'm trying to accomplish:

      <cfif IsDefined("Form.button1")>
      do this.....
      <cfelseif IsDefined("Form.button2")>
      do this....
      <cfelseif IsDefined("Form.button3")>
      do this...
      <cfelse>
      do this...
      </cfif>

      <form action="page1.cfm" method="post" name="theForm">
      <input type=button name=button1 value="Add" onClick="submitForm()">
      <input type=button name=button2 value="Subtract" onClick="submitForm()">
      <input type=button name=button3 value="Multiply" onClick="submitForm()">
      </form>


      When a user clicks on a button it fires off a javascript routine that simply submits the form/page to itself.

      Let me know if you need more detail than this.

      Thanks.

      Comment


      • #4
        I never have used cfform in apps because you can not have duplicate field names on your form.

        <cfif IsDefined("Form.button1")>

        should be

        <cfif IsDefined("#Form.button1#")>
        does this sig match?

        Comment


        • #5
          I'll give it a try. Thanks for your help.

          Comment


          • #6
            No dice. A whipped-up a test page and it didn't work too well. Give it a try...

            <html>
            <head>
            <script language="JavaScript">
            function submitIt()
            {
            document.theForm.submit();
            }
            </script>
            </head>

            <cfif IsDefined("#Form.button1#")>
            <cfoutput>button1</cfoutput>
            <cfelseif IsDefined("#Form.button2#")>
            <cfoutput>button2</cfoutput>
            <cfelseif IsDefined("#Form.button3#")>
            <cfoutput>button3</cfoutput>
            <cfelse>
            <cfoutput>NObutton</cfoutput>
            </cfif>

            <body>
            <form name="theForm" action="buttonTest.cfm" method="post">
            <input type="Button" name="button1" value="Button1" onclick="submitIt()">
            <input type="Button" name="button2" value="Button2" onclick="submitIt()">
            <input type="Button" name="button3" value="Button3" onclick="submitIt()">
            </form>
            </body>
            </html>

            Any suggestions? Thanks.

            Comment


            • #7
              Try the

              <cfif IsDefined("#Form.button1#")>

              without the quotes.

              Then try just a
              <cfoutput>#form.button1#</cfoutput>

              If it is returning the right value then you may need to modify your <cfif> statements. I do not have a cf server at work so I can not test your code.
              does this sig match?

              Comment


              • #8
                aandrew,

                Sorry for the bad info. Your form does not pass the button value at all. I do not know if that is a html or cfm issue. I added a hidden field to set whatever value you are trying to pass. I also used the cfswitch instead of cfifs. Hope this helps.

                <html>
                <head>
                <script language="JavaScript">
                function submitIt(v)
                {
                document.frmTest.hdnAction.value = v;
                document.frmTest.submit();
                }
                </script>
                </head>
                <cfif isdefined("form.hdnAction")>
                <cfswitch expression="#hdnAction#">
                <cfcase value="Uno">
                Script One
                </cfcase>
                <cfcase value="Dos">
                Script Two
                </cfcase>
                <cfcase value="Tres">
                Script Three
                </cfcase>
                <cfdefaultcase>
                No Script
                </cfdefaultcase>
                </cfswitch>
                </cfif>


                <body>
                <form name="frmTest" action="Test.cfm" method="post">
                <input type=hidden name=hdnAction>
                <input type="Button" name="button1" value="Button1" onclick="submitIt('Uno')">
                <input type="Button" name="button2" value="Button2" onclick="submitIt('Dos')">
                <input type="Button" name="button3" value="Button3" onclick="submitIt('Tres')">
                </form>
                </body>
                </html>
                does this sig match?

                Comment


                • #9
                  allida77,

                  Worked like a charm. Your a life-saver. Been bangin' my head on the desk for a week trying to firgure this out. Thanks for your help.

                  Comment

                  Working...
                  X