#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Location
    Norwich
    Posts
    53
    Rep Power
    11

    Angry coldfusion navigation problem


    hi,

    I am performing a search through a form and want to limit the number of items displayed. I have got this working but when the next button is pressed tp display further results I get the following error message:

    Element LISTTYPE is undefined in FORM.


    On the first page in debugging I have the following elements.

    Form Fields:
    FIELDNAMES=LISTTYPE,LISTBEDROOM,LISTTOWN,LISTPRICE,SUBMIT
    LISTBEDROOM=value
    LISTPRICE=value
    LISTTOWN=value
    LISTTYPE=value
    SUBMIT=Property Search

    These aren't in debugging when next is pressed so I assume they are not in scope.


    How do i pass these form fields using navigation?

    I am using a repaet region server behaviour.

    Hope you can help.

    Thanks

    peter
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,273
    Rep Power
    968
    You must create hidden form fields to pass the form elements on to another page. You can do this manually, or you can loop over the form.fieldlist list and create the hidden form elements automatically. But when the user presses submit on the second form, if you have not moved your form values into hidden form fields they won't be posted to the next form.

    You could also look into storing them in a shared scope such as session or client variables.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Location
    Norwich
    Posts
    53
    Rep Power
    11

    creating hidden form fields


    Thanks for your help.
    I'm still very new to coldfusion.
    Have you got any sample code i could look at to give me an idea of creating hidden form fields and how to pass the form elements on to another page please?

    If I have displayed some of the results on one page and pass over the form elements will the next page display correctly. e.g if page one displays records 1 to 5 will the next page display records 6 to 10 and so on?

    I have to congratulate you on running the best forum that I have found and I have looked at very many.

    Cheers

    peter
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,273
    Rep Power
    968
    You can do it two ways. Manually:

    <cfoutput>
    <input type="hidden" name="listtype" value="#form.listtype" />
    <input type="hidden" name="listbedroom" value="#form.listbedroom#" /> ....etc....
    </cfoutput>

    Or automatically (you may need to manually omit the submit value depending on what you need to do):

    <cfloop index="thisField" list="#form.fieldnames#" delimiters=",">
    <input type="hidden" name="#thisField#" value="#form.fieldnames[thisField]#" />
    </cfloop>
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Location
    Norwich
    Posts
    53
    Rep Power
    11
    Hi,

    I wasn't exactly sure where to insert the code so tried it in the search form. When I refreshed the page I got the following error message:

    ColdFusion was looking at the following text:
    \"

    The CFML compiler was processing:

    An expression that began on line 132, column 45.
    Your expression might be missing an ending "#" (it might look like #expr ).
    The body of a cfoutput tag beginning on line 131, column 21.


    The error occurred in C:\CFusionMX\wwwroot\Bernada Test Site PETE\Templates\NoTemplate.cfm: line 132

    130 :
    131 : <cfoutput>
    132 : <input type="hidden" name="listtype" value="#form.listtype" />
    133 : <input type="hidden" name="listbedroom" value="#form.listbedroom#" />
    134 : </cfoutput>



    This is the code for the entire form.



    <table>


    <tr><form action="ResultsNavigation.cfm" method="post" name="frmSearch">


    <td align="right" valign="centre">
    <select name="ListType">
    <option value="value">Type of property</option>
    <cfoutput query="q_saletype">
    <option value="#q_saletype.sale_type#">#q_saletype.sale_type#</option>
    </cfoutput>
    </select>
    <select name="ListBedroom" id="select">
    <option value="value">Bedrooms</option>
    <cfoutput query="q_bedroom">
    <option value="#q_bedroom.room_bedroom#">#q_bedroom.room_bedroom#</option>
    </cfoutput>
    </select>
    <select name="ListTown">
    <option value="value">Location</option>
    <cfoutput query="q_town">
    <option value="#q_town.townname#">#q_town.townname#</option>
    </cfoutput>
    </select>

    <select name="ListPrice">
    <option value="value">Price range</option>
    <cfoutput query="q_price">
    <option value="#q_price.price#">#q_price.price#</option>
    </cfoutput>
    </select>


    This is probably in the wrong place?: Should it be on thius page or the results page of the form action e.g ResultsNavigation.cfm


    <cfoutput>
    <input type="hidden" name="listtype" value="#form.listtype" />
    <input type="hidden" name="listbedroom" value="#form.listbedroom#" />
    </cfoutput>


    <input type="submit" name="Submit" value="Property Search"></td></form> </tr>



    </tr>
    </table>


    Hopefully will get this working with a little bit more assistance.

    Thanks for your help.

    Cheers

    Peter
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Location
    Norwich
    Posts
    53
    Rep Power
    11
    I have also tried the cfloop code but still get error message of:

    element fieldnames is undefined.


    <cfloop index="thisField" list="#form.fieldnames#" delimiters=",">
    <input type="hidden" name="#thisField#" value="#form.fieldnames[thisField]#" />
    </cfloop>

    The missing # at the end of '#form.ListType' wasn't the problem with the manual solution.

    Cheers

    Peter
  12. #7
  13. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,273
    Rep Power
    968
    form.fieldnames will only be available on a TARGET page, a page to which you have POSTED a form. So that is where you want to put the code. If form.fieldnames is not defined then you are referencing that variable on a page that has not had a form posted to it. Try wrapping the code in a check to confirm that form.fieldnames is defined:

    <cfif isDefined( 'form.fieldnames' )>
    ...manual or loop code to carry over the posted form fields goes here...
    </cfif>

IMN logo majestic logo threadwatch logo seochat tools logo