Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

how i get the value from form to url

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">
  <tr>
     <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>
        </cfoutput>
      </select></td>
    <td width="3%" align="right"><input type="submit" name="view" id="view" value="Go" tabindex="2" class="submit" style="width:25px; height:23px;"></td>
  </tr>
</table>
</cfform>
 
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>
      </tr>
    </cfoutput>
    <tr>
      <td colspan="5" align="center"><cfoutput>#pagination.getRenderedHTML()#</cfoutput></td>
    </tr>
</cfif>
 
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") />
<cfelse>
<cfset pagination.setBaseLink("index.cfm") />
</cfif>
<cfset pagination.setItemsPerPage(2) />
<cfset pagination.setUrlPageIndicator("page") />
<cfset pagination.setShowNumericLinks(true) />

Open in new window

0
Gurpreet Singh Randhawa
Asked:
Gurpreet Singh Randhawa
1 Solution
 
SidFishesCommented:
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="window.open(this.options[this.selectedIndex].value,'_self')">
<OPTION VALUE="" SELECTED>--Select -- </option>
<cfloop query="cme">
<OPTION value="thispage.cfm?cat_id=#cat_id#>#cat_name#
</cfloop>
</SELECT>

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

you could also do

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

<cfelse>

       filter/pagination code here
</cfif>

which would hide the select after iniital selection
0
 
Gurpreet Singh RandhawaWeb DeveloperAuthor Commented:
Yes! You Rock
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now