473,796 Members | 2,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Alphabetic letter based search

16 New Member
Hi,

i have list of alphabets from A to Z .if i click on any one letter that should give me all the name starting with that corresponding letter from the database and should be displayed in the same page.

if i use each letter as a link(link_to) i cant display them in the same page.

if i use link_to_remote i am not able to get the params value of the letter i.e...Which letter i clicked.. if anyone know about this plz give me a solution.
Mar 25 '09 #1
3 4262
improvcornartist
303 Recognized Expert Contributor
You could try Rails AJAX support to send the database results to a div within the same page. Or you could try using a partial.
Mar 25 '09 #2
dakshayini
16 New Member
Expand|Select|Wrap|Line Numbers
  1. <%= javascript_include_tag "prototype" %>
  2. <div class="element_links">
  3. <% for char in 'A'..'Z' %>
  4. <%= link_to_remote( "#{char}",
  5.                          :update => "content",
  6.                          :char => char,
  7.                          :url =>{:action => :alp_search }) %> </li>
  8.                          <% end %> 
  9.                          <div id="content"></div>
  10.                     <p>
  11. <ul>
This is my rhtml

and my controller is

Expand|Select|Wrap|Line Numbers
  1. def live_search
  2.      puts 'live_search'
  3.            @classifieds = Course.find(:all,:conditions => ["lower(course_name)like ?","%" + params[:search].downcase+ "%"])
  4.            puts @classifieds
  5.            if params['search'].to_s.size < 1
  6.            render :nothing => true
  7.            else
  8.                 if @classifieds.size > 0
  9.                    render :partial => 'display', :collection => @classifieds
  10.                    else
  11.                    render :text => "<li>No results found</li>", :layout => false
  12.                    end
  13.                 end
  14.               end

So as per the code if i click 'A' i should get all the courses which starts from 'A' from the database but am not able to get the params value of search.

In the place of link_to_remote if i use link i can get the correct result in the other page..but i want to display result in the same page..
is there is any way to do this...
Apr 3 '09 #3
improvcornartist
303 Recognized Expert Contributor
Try adding content to your content div, such as
Expand|Select|Wrap|Line Numbers
  1. <div id="content">
  2.   <%= @content %>
  3. </div>
  4.  
Then, in your controller, set the content variable with the partial, like
Expand|Select|Wrap|Line Numbers
  1. def live_search
  2.   #...code...
  3.   @content = render_to_string(:partial => 'display', :collection => @classifieds)
  4.  
  5.   render :update do |page|
  6.     page.replace_html 'content', @content
  7.   end
  8. end
This should then update the div with your partial using your data collection.
Apr 3 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

12
6034
by: Alan J. Flavell | last post by:
OK, today's email brought a comment from a reader, pointing out something that I'd long since noticed myself but hadn't done anything about it. On my pages, I've got a first-letter style on paragraphs. So far, so good: some of the paragraphs begin with a link, and there are styles in the stylesheet for link, hover etc. The first letter is still displayed as styled for the paragraph's first-letter.
13
4885
by: Ian Richardson | last post by:
At the moment I'm using a quicksort algorithm to sort a list of countries in alphabetic order. This worked wonderfully until someone came up with the Åland Islands... and this is at the end of the list. I'm not sure it's supposed to be. Now I could just alter my comparison so it ignores the top bit, but this would then put it at the top of the list, even before Albania... Alternatively, should I put Å after A?
4
12538
by: George Thompson | last post by:
How can I retrieve the first letter of data in a field within access? (using access 2k?) is this a VB thing or is there an obvious solution?
0
1649
by: Tim::.. | last post by:
Hi... I'm having a big problem with a datagrid that obtains data from 2 different locations... Active Directory and SQL Database The data is inserted into a datatable and the sorted by a dataview... however due to alphabetic paging and the postback ("I think") the contacts from the SQL Database appear on ever page when you page through the datagrids
5
3862
by: Xero | last post by:
How do you get a specific letter from a word? For example, in English, I would say: Get the fifth letter from the word "Computer" Then the letter 'u' will be returned. (C-O-M-P-U-..., 'u' is the fifth letter) How do you 'translate' this sentence into VB.net? Thanks! -- Xero
2
2120
by: news | last post by:
We're trying to make a search form, and are wanting to create links for all the letters a person can click on and will bring up all entries that start with that letter. That part is easy: .... WHERE field LIKE '$letter%' But we'd like to also have one a person can click on for numbers and punctuation. Is there a built-in mySQL querey component where you can search for entries in a column that start with a non-letter?
3
3010
by: PulkitZery | last post by:
Hi all, I need some help in my project (VB.NET) here is what I need: I need to convert Alphabetic number (a. b. c. d. …..) into the integers (for example a=1, b=2, c=3 and so on). Can anyone give me a function or point me to an article that explains how to convert these alphabetic number into the integers. Thanks very much in advance. Jerry.
7
1563
by: emre esirik(hacettepe computer science and enginee | last post by:
I used a structer in this program. typedef struct _guitar { int serial; :serial of item at the guitar store int price; :price of item at the guitar store char builder; :builder of item at the guitar store char type; :type of item at the guitar store char model; :model of item at the guitar store }guitar;
8
5496
crystal2005
by: crystal2005 | last post by:
Hi guys, Just like the title, i'm looking for the example of C program that translates an alphabetic phone number into numeric. The idea as the following output Enter phone number: 1800-TEST-100 result: 1800-8378-100 so basically 2=ABC, 3=DEF, 4=GHI, . . . , 9 = WXYZ
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10459
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10237
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7553
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5446
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3735
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.