4 Replies Latest reply on Jan 23, 2013 5:14 PM by wannab0133

    nesting cfform behavior....

    wannab0133 Level 1

      I have the following code and I have tested it in chrome and IE:


      <cfform name="form1" action="http://www.yahoo.com" method="post" >


           <cfloop index="X" from="1" to="9">

              <cfform name="form2" action="http://www.google.com" method="post">

                  <cfinput type="submit" name="GOOGLE" value="GOOGLE#X#">




      <cfinput type="submit" name="YAHOO" value="YAHOO">



      All the google buttons should submit and go to google.com....The yahoo button should go to yahoo.com.  I have code similar to this working elsewhere in my application, but this one has me stumped.  The first buton in the loop(when x is 1), is surrounded by the form1 tags and goest to yahoo.com, and the remaining buttons are surrounded by form2 tags and go to google.com like they are supposed to.  The final yahoo button is not surounded by a form tag at all and does nothing.  I know there is something I am missing....I thought you couldnt nest from tags, but I do it elsewhere and it works fine.  I feel like it is something easy I am missing.  HELP!

        • 1. Re: nesting cfform behavior....
          WolfShade Level 4

          Even if it works, you cannot nest form tags.



          • 2. Re: nesting cfform behavior....
            wannab0133 Level 1

            If it works, I guess I CAN nest forms.


            I have code in production for years with nested forms much more complicated than this.  I am not worried about this project, but now I have to go back and fix the code that shouldnt work.

            • 3. Re: nesting cfform behavior....
              Dan Bracuk Level 5

              It's hard to tell with the code you posted, especially when you use the term "surrounded by".  The code you posted should show 10 buttons labeled google 1-9, then yahoo. 

              • 4. Re: nesting cfform behavior....
                wannab0133 Level 1

                It does show 10 buttons in total.  The first and 10th buttons do not function like I would expect them to.  The first button, google 1, goest to yahoo.com rather than to google.com.  The last button, does nothing because it is never within the html form tags after coldfusion generates the html.  It is within the cfform tags, but not the html form tags.  I use the inspect feature in chrome and can see the html that is being generated contradicts the cfml.  Throw it in a cfm file and run it.  Then, inspect each button.  I am really curious why this happens.


                I can make my page do something else, and I probably will rather than nesting the form tags.  I am glad I stumbled upon this because maybe I can save myself some headache later on.  However, there are conflicting reports online whether you can nest the cfform tags.  I hear it wont work in html, and other I hear do it regularly.