how i get the value from form to url

Posted on 2009-04-16
Last Modified: 2013-12-24
Hi experts, i have one combobox which gets the value of records from database.

Suppose there are 100 records in adatabase and i retrieve the records using thee cfform post method by which it passes the value in a form field.

i tend to use the paging where i want to use to display 20 records @ at a time.

Is there any way i can automatically convert the form value to url and paging should work fine

Something below i have:

<cfform method="post" action="index.cfm?action=products">

<table width="100%" border="0" cellspacing="2" cellpadding="1">


     <td width="61%" align="right">View Products In:&nbsp;</td>

    <td width="14%" align="right"><select name="cboCategory" id="cboCategory" tabindex="1" class="textfield_effect">

        <option selected value="0">All Category</option>

        <cfoutput query="sme">

            <option value="#cat_id#">#cat_name#</option>



    <td width="3%" align="right"><input type="submit" name="view" id="view" value="Go" tabindex="2" class="submit" style="width:25px; height:23px;"></td>




now i have something like this:

<cfif isDefined('form.view')>

 <cfoutput query="sme" startrow="#pagination.getStartRow()#" maxrows="#pagination.getMaxRows()#">

      <tr align="left">

        <td width="376">#trim(pd_name)#</td>

        <td width="160"><cfif pd_thumbnail IS ""><em><div align="center"><strong>No Image</strong></div></em><cfelse><img src="products/thumbnails/#pd_thumbnail#"></cfif></td>

        <td width="305">#cat_name#</td>

        <td width="74"><a href="?action=products&eID=#URLEncodedFormat(pd_id)#&add2=yes">Edit</a></td>

        <td width="70"><a href="?action=products&deleteID=#URLEncodedFormat(pd_id)#" onClick="return confirm('Are you sure');">Delete</a></td>




      <td colspan="5" align="center"><cfoutput>#pagination.getRenderedHTML()#</cfoutput></td>



pagination code:

<cfset pagination = createObject("component", "#request.cfcPath#.Pagination").init()/>

<cfset pagination.setQueryToPaginate(sme) />

<cfif IsDefined('url.action') AND url.action eq 'products'>

<cfset pagination.setBaseLink("index.cfm?action=products") />


<cfset pagination.setBaseLink("index.cfm") />


<cfset pagination.setItemsPerPage(2) />

<cfset pagination.setUrlPageIndicator("page") />

<cfset pagination.setShowNumericLinks(true) />

Open in new window

Question by:myselfrandhawa
    LVL 36

    Accepted Solution

    it looks to me like your form is only to trigger your filter/pagination?

    if that's the case you might look at just using a select with no form with some js to reload the page with a url variable

    <SELECT NAME="SelectIndex" onChange="[this.selectedIndex].value,'_self')">
    <OPTION VALUE="" SELECTED>--Select -- </option>
    <cfloop query="cme">
    <OPTION value="thispage.cfm?cat_id=#cat_id#>#cat_name#

    <cfif structkeyexists(url, "cat_id")><!--- all on same page as select, will only show when url.cat_id exists --->
           filter/pagination code here

    you could also do

    <cfif NOT structkeyexists(url, "cat_id")>
    <SELECT NAME="SelectIndex" onChange="[this.selectedIndex].value,'_self')">
    <OPTION VALUE="" SELECTED>--Select -- </option>
    <cfloop query="cme">
    <OPTION value="thispage.cfm?cat_id=#cat_id#>#cat_name#


           filter/pagination code here

    which would hide the select after iniital selection
    LVL 15

    Author Closing Comment

    Yes! You Rock

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
    When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure ( It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
    The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
    The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now