|
Welcome, Guest. Please Login or Register. Nov 20th, 2008, 1:19pm
Author |
Topic: Putting saved searches in a drop-down (Read 441 times) |
|
Balok
Full Member
  
What, me worry?
Posts: 64
|
 |
Putting saved searches in a drop-down
on: Jul 31st, 2008, 4:20pm |
Quote | Modify
|
I've been trying to devise a way to put the list of saved searches into a dropdown. I've figured out how to use <dax:search> to iterate over them and <dax:searchname/> to get their names, but what I can't figure out is how to get the links. When I try to pass </dax:searchlink> or <dax:searchlink><dax:searchlink/> to a bit of Javascript, I get errors. (I was figuring on building an options list for the dropdown.) Can this be done? If so, how? Thanks.
|
|
IP Logged |
|
|
|
Andrei
Administrator
    
Email
Posts: 1172
|
 |
Re: Putting saved searches in a drop-down
Reply #1 on: Aug 7th, 2008, 12:36am |
Quote | Modify
|
Probably not the most straightforward way, but it works. Place this code snippet where you want a dropdown: Code:<!-- hidden div with generated search links --> <div id="hidden_links" style="display: none"> <dax:search> <dax:searchlink><dax:searchname/></dax:searchlink > </dax:search> </div> <!-- actual dropdown, prepopulated with one initial element. The rest will be added programmatically --> <select id="search_dropdown" onchange="if(this.value){ document.getElementById('search_' + this.value).click() }"> <option>Select search</option> </select> <script type="text/javascript"> // populate drop-down var div = document.getElementById('hidden_links'); var sel = document.getElementById('search_dropdown'); var i, links = div.getElementsByTagName('a'); for (i = 0; i < links.length; i ++) { var o = document.createElement("option"); o.text = links[i].innerText; o.value = i; links[i].id = 'search_' + i; sel.add(o); } </script> |
|
|
IP Logged |
|
|
|
Balok
Full Member
  
What, me worry?
Posts: 64
|
 |
Re: Putting saved searches in a drop-down
Reply #2 on: Aug 8th, 2008, 7:14pm |
Quote | Modify
|
Thanks! This worked great! Now I don't have to worry that a large number of searches will crowd the template.
|
|
IP Logged |
|
|
|
BLOWERS
Senior Member
   
If all else fails, read the question...
Posts: 158
|
 |
Re: Putting saved searches in a drop-down
Reply #3 on: Aug 14th, 2008, 10:40am |
Quote | Modify
|
Hi Andei, on Aug 7th, 2008, 12:36am, Firetongue wrote:Probably not the most straightforward way, but it works. Place this code snippet where you want a dropdown: Code:<!-- hidden div with generated search links --> <div id="hidden_links" style="display: none"> <dax:search> <dax:searchlink><dax:searchname/></dax:searchlink > </dax:search> </div> <!-- actual dropdown, prepopulated with one initial element. The rest will be added programmatically --> <select id="search_dropdown" onchange="if(this.value){ document.getElementById('search_' + this.value).click() }"> <option>Select search</option> </select> <script type="text/javascript"> // populate drop-down var div = document.getElementById('hidden_links'); var sel = document.getElementById('search_dropdown'); var i, links = div.getElementsByTagName('a'); for (i = 0; i < links.length; i ++) { var o = document.createElement("option"); o.text = links[i].innerText; o.value = i; links[i].id = 'search_' + i; sel.add(o); } </script> | | This works well. My only problem is that I don’t know how to reduce the pointsize of the text in the box. A little help on how to do this would be very welcome!
|
|
IP Logged |
Malc
|
|
|
Balok
Full Member
  
What, me worry?
Posts: 64
|
 |
Re: Putting saved searches in a drop-down
Reply #4 on: Aug 26th, 2008, 4:37pm |
Quote | Modify
|
on Aug 14th, 2008, 10:40am, BLOWERS wrote:| My only problem is that I don’t know how to reduce the pointsize of the text in the box. A little help on how to do this would be very welcome! | Your best choice is the CSS stylesheet. Add this: Code:#search_dropdown { font-size: 70%; } | somewhere in your CSS tab. You can use percentages, point sizes, inches or cm to define the font size as you like. If you changed the value in the <SEARCH> tag's ID attribute, be aware that what follows the # in the example above must match that value. What I gave you works with the code Andrei provided above (I tested it).
|
|
IP Logged |
|
|
|
BLOWERS
Senior Member
   
If all else fails, read the question...
Posts: 158
|
 |
Re: Putting saved searches in a drop-down
Reply #5 on: Aug 27th, 2008, 3:25am |
Quote | Modify
|
Fantastic, Balok - works a treat! Thanks very much for your help.
|
|
IP Logged |
Malc
|
|
|
|