Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Javascript and Links

Quote Reply
Javascript and Links
I'm looking to use a javascript to filter a large list of categories.
Users can search and choose the categories of choice on the add.html page.
Then send it to Links SQL for addition to the database.

The problem is that this script calls the FORM and SELECT list like:
var filter = new filterlist(document.usersform.usersselect);

Form name is no problem, but I need it to call the select list punctuated with a full stop "CatLinks.CategoryID" so it sends it correctly to the database like the following:

var filter = new filterlist(document.usersform.CatLinks.CategoryID);

( If I put a full stop in the SELECT list it comes up with an error.)

Any help appreciated.

Thanks

Regards

minesite
Quote Reply
Re: [minesite] Javascript and Links In reply to
I had a similar problem with getting the 'add to multiple categories' modification. I never actually found a way to escape the . in it. Sorry I can't be of more help, but I'm just warning you, that your attempts may be futile :(

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Javascript and Links In reply to
I posted the same details on the on BarelyFitz Forum and they replied with:

Alternate way of referring to the select element:
Code:
document.usersform.elements['CatLinks.CategoryID']

Seems to be working Ok at this stage, its quite a good script for sorting large categories.( 1300 )
Uses the <%Category%> , changes are necessary to the include_form.html, add.html and the add_success.html
I had already changed the Add.pm so I could use multiple category additions.

If anyone is interested it can be found at http://www.barelyfitz.com/webdesign/articles/filterlist/
and the best part, its open source.

Regards

minesite
Quote Reply
Re: [minesite] Javascript and Links In reply to
Good one there Oz.
That appears to be the answer to a lot of peoples problems.
Any chance of posting the full mod?
Quote Reply
Re: [Gypsypup] Javascript and Links In reply to
Gypsypup, as requested.

1 st Visit the Web Site listed in the above post, read the installation FAQ and download the script and sample template.
2 nd back up all files you are going to modify.
3 rd back up all files you are going to modify.

Then

In add.html put the following between <head> </head> tags.
<SCRIPT src="http://whereyourfilterlistresides.com/filterlist.js" type=text/javascript>
</SCRIPT>

Also in add.html change:
<form action="<%db_cgi_url%>/add.cgi" enctype="multipart/form-data" method="POST"> to
<form name="usersform" action="<%db_cgi_url%>/add.cgi" enctype="multipart/form-data" method="POST">

Then

Line 195 in Links/User/add.pm
Change:
$category = $html->get_all_categories(\@ids, 'CatLinks.CategoryID', 5);

Then

In the include_form.html
Delete <%Category%> and replace with the following:

Please Note:This does not need changing at this stage.

<!-------------------- START Filter List -------------------------->
<table width="100%">
<tr><td>
<!-- Message for filtered results -->
<DIV id=filtertext> </DIV>
</td></tr>
<tr><td><%Category%></td></tr>
</table>
<SCRIPT type=text/javascript>
//<![CDATA[
<!--
var filter = new filterlist(document.usersform.elements['CatLinks.CategoryID']);

filter.hook = function() {

if (document.getElementById) {
var id = document.getElementById("filtertext");
if (typeof id.innerHTML != 'undefined') {
if (this.selectobj.length == this.optionscopy.length) {
id.innerHTML = "&nbsp;";
} else {
id.innerHTML = "Showing " +
this.selectobj.length + " of " +
this.optionscopy.length + " items";
}
}
}
}

function dofilter(regexp)
{document.usersform.regexp.value = regexp;
filter.set(regexp);
}
//-->
//]]>
</SCRIPT>

<table width="100%">
<tr><td>
<A title="Show all items" href="javascript:dofilter('')">[ List All ]</A>Alpha List
<A title="Show items starting with A" href="javascript:dofilter('^A')">A</A>
<A title="Show items starting with B" href="javascript:dofilter('^B')">B</A>
<A title="Show items starting with C" href="javascript:dofilter('^C')">C</A>
<A title="Show items starting with D" href="javascript:dofilter('^D')">D</A>
<A title="Show items starting with E" href="javascript:dofilter('^E')">E</A>
<A title="Show items starting with F" href="javascript:dofilter('^F')">F</A>
<A title="Show items starting with G" href="javascript:dofilter('^G')">G</A>
<A title="Show items starting with H" href="javascript:dofilter('^H')">H</A>
<A title="Show items starting with I" href="javascript:dofilter('^I')">I</A>
<A title="Show items starting with J" href="javascript:dofilter('^J')">J</A>
<A title="Show items starting with K" href="javascript:dofilter('^K')">K</A>
<A title="Show items starting with L" href="javascript:dofilter('^L')">L</A>
<A title="Show items starting with M" href="javascript:dofilter('^M')">M</A>
<A title="Show items starting with N" href="javascript:dofilter('^N')">N</A>
<A title="Show items starting with O" href="javascript:dofilter('^O')">O</A>
<A title="Show items starting with P" href="javascript:dofilter('^P')">P</A>
<A title="Show items starting with Q" href="javascript:dofilter('^Q')">Q</A>
<A title="Show items starting with R" href="javascript:dofilter('^R')">R</A>
<A title="Show items starting with S" href="javascript:dofilter('^S')">S</A>
<A title="Show items starting with T" href="javascript:dofilter('^T')">T</A>
<A title="Show items starting with U" href="javascript:dofilter('^U')">U</A>
<A title="Show items starting with V" href="javascript:dofilter('^V')">V</A>
<A title="Show items starting with W" href="javascript:dofilter('^W')">W</A>
<A title="Show items starting with X" href="javascript:dofilter('^X')">X</A>
<A title="Show items starting with Y" href="javascript:dofilter('^Y')">Y</A>
<A title="Show items starting with Z" href="javascript:dofilter('^Z')">Z</A>
</td></tr><tr><td>
Keyword Search:
<INPUT name=regexp>
<INPUT onclick=filter.set(this.form.regexp.value) type=button value=Search>
<INPUT onclick="filter.reset();this.form.regexp.value=''" type=button value=List_All>
</td></tr></table>
<!--------------- END Filter List ----------------------------->

Do not make any changes to the above code until you have it working, then make changes to suit.

Then
Make sure you have followed steps 2 and 3 at the start of this post.
Copy all files to the relevant directories, including the filterlist.js
( The filterlist.js does not need changing )

You may get an error message in the add_success.html confirmation page.
You could delete the following from add_success.html and it should go away.
<tr><td><%body_font%>Category:</td><td><b><%Category%></b></font></td></tr>

It will just mean the user does not see the categories that they listed in on the success page, no big deal.

Check the details when you validate and all should be OK.

Please Note: This has only been tested on a development site, not a live site.

Good luck.

PS I removed the "real time" filtering, if you need it just replace:

<input name=regexp> with
<input onkeyup=myfilter.set(this.value)name=regexp>

but not until you have it working.

Regards

minesite