Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Location
    Virginia
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 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
    Regular Coder
    Join Date
    Jun 2002
    Location
    Cincinnati, OH
    Posts
    545
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are using cfform of just a regular form? Can you post some code?

  • #3
    New to the CF scene
    Join Date
    Jul 2002
    Location
    Virginia
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Cincinnati, OH
    Posts
    545
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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#")>

  • #5
    New to the CF scene
    Join Date
    Jul 2002
    Location
    Virginia
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'll give it a try. Thanks for your help.

  • #6
    New to the CF scene
    Join Date
    Jul 2002
    Location
    Virginia
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #7
    Regular Coder
    Join Date
    Jun 2002
    Location
    Cincinnati, OH
    Posts
    545
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Location
    Cincinnati, OH
    Posts
    545
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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>

  • #9
    New to the CF scene
    Join Date
    Jul 2002
    Location
    Virginia
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •