Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating an option (all) in list box

Status
Not open for further replies.

omerdurdu

Programmer
Joined
Jul 21, 2001
Messages
72
Location
TR
In my search form I have a list box. I pick a name and search for the criteria. How can I create an option in the list box to search all names. I mean
<option>all
<option>alcin
<option>batin
.
.
.

Thanks,
 
The best way is... on the form page:

Code:
<SELECT name=&quot;lstOp&quot;>
  <OPTION value=&quot;987!654!321!0&quot;>All</OPTION>
  <!--- The above is something very unlikely to be in the 
        list, that's while we'll use it --->
  <OPTION value=&quot;alcin&quot;>Alcin</OPTION>
  <OPTION value=&quot;batin&quot;>Batin</OPTION>
</SELECT>

on the results page... us a cfif...

Code:
<CFIF form.lstOp is not &quot;987!654!321!0&quot;>
search stuff based on all here
Code:
</CFIF>
 
Am I wrong in thinking that you want to search all of a certain field? Why not set the value of all to '*' so when you create you query the wildcard is entered for the search.
Erwin Oosterhoorn
Analyst Programmer,
Roller hockey'er, biker, ice hockey fan.
 
Although the * idea sounds like a good idea...
I tried it in SQL Query analyzer and it errors out.

I use the option described above, except I use &quot;&quot; as the value. I then wrap the were clause with an If Statement to block it from the query.

SELECT locationID, shortname
FROM tb_Locations
<CFIF #val(url.id)# neq &quot;&quot;>
where locationID = #VAL(url.id)#
</CFIF>

The VAL() help keep you from danger with hackers addind drop table..

David McIntosh
 
Actualy, you should use <cfqueryparam> if you ever use variables in a query.
 
Actualy, you should use <cfqueryparam> if you ever use form or url variables in a query.
 
What exactly does the query that you do the search in look like?

I use a similar function, I have a search form that I can choose to search by firstname or lastname or search all name fields (first/last).

My query looks something like this:


<cfquery name=&quot;do_search&quot; datasource=&quot;#application.ds#&quot;>
select * from table
<cfif form.search is 'first'>
where firstname = '%#form.criteria#%' <!--- searches only firstname --->
<cfelseif form.search is 'last'>
where lastname = '%#form.criteria#%' <!--- searches only lastname --->
<cfelseif form.search is 'all'>
where firstname = '%#form.criteria#%' or lastname='%#form.critera#%' <!--- searches all name fields --->
</cfif>
</cfquery>


The select is only part of the solution, the other half has to be in the query itself.

Hope this helps.
 
Thank you so much for replying. I have a question about a passing variables.

I have a report page, and I wanna edit it but when I click edit button there is a login form page and it will ask username and password. When I enter my username and password I can get into edit page but having problem passing a variable which is ID number. Can you help me on this. How am I gonna pass this ID variable from report page through the login page to edit page.
Thanks for helping.
 
Pass to like... login.cfm?ID=1 and then in the login form...

<INPUT type=&quot;hidden&quot; name=&quot;hid&quot; value=&quot;#url.id#&quot;>

In the edit page call #form.hid#...

or your form action could be

edit.cfm?eid=#url.id#

HTH,
Tony
 
Hi Tony,
Thank you so much again.
Let me explain like this.
I have a report page. I wanna edit it. There is an eidt button on the left. But I have to have username password where I did that in LoginForm.cfm.
when i click on edit button, link is like this:

I am going to loginform page where asking username and password, when I enter my password and username I am get into edit page where i am having error. It is asking what is Dataset_ID. Seems I cant pass the variable to the edit page because of LoginForm.cfm

Thanks
 
Show me the code of loginform.cfm please... I'll edit it appropriately, also the query in your edit page that is based on dataset_id.cfm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top