Ajax AutoComplete Support Product Page

Answered

adding title and extra field beside eachother instead of under eachother?

Asked 14 Mar 2011 12:59:03
2
have this question
14 Mar 2011 12:59:03 Didier Glorieux posted:
HI guys,

just a small question.
In the result of the ajax, is there any possibility to add the extra field on the same line as the initial field?

for example I have article numbers and then the article title.
now the title is placed under the article number, I just want the title at the same line, any idea how to do this?

example now :
123456
title article

i want :
123456 - title article.

thanx for any clue

Replies

Replied 25 May 2011 13:47:32
25 May 2011 13:47:32 Chris Trace replied:
any luck on getting this resolved?
Replied 26 May 2011 10:56:35
26 May 2011 10:56:35 Miroslav Zografski replied:
Hello,

That is achievable. However it involves altering a code of the extension.

If you make that change and something unexpected happens we may deny to provide you with support.

Basically the change is made in the autocomplete-PageName-asp/php-#.asp/php file

Depending on your server side different things are changed.

Provide more information for your server side if you like to get a specific instructions.

Regards,
Replied 26 May 2011 12:09:59
26 May 2011 12:09:59 Chris Trace replied:
thanks for the reply

i dont think that it would affect the extension that much really since it really is just a layout issue

the only echo i can find on the php page though is

while ($row = mysql_fetch_array($res, MYSQL_NUM))
{
echo join("|", $row)."\n" ;

how the $fields = implode(',',array_map('convert',$fields));

relates to that i am not sure - i had a play (backed up file first)

but couldnt get the two $field then $fields in line

would appreciate the tweak really since it does look better especially if you are using things like Surname, Firstname on the same line

running php server with sql5 - if you need anything else please just ask

cheers

Edited by - Chris Trace on 26 May 2011  12:10:46
Replied 29 May 2011 05:30:33
29 May 2011 05:30:33 Chris Trace replied:
actually a really handy thing would be to allow the drop down only to search by user variable as well

i am playing with this atm

$sql = 'SELECT '.$fields.' FROM `'.$table.'` WHERE username = "$_SESSION['MM_Username']"';

just trying to get the syntax right

any thoughts
Replied 29 May 2011 14:04:24
29 May 2011 14:04:24 Chris Trace replied:
got it - now ajax has filters such as username or userid
Replied 30 May 2011 09:53:47
30 May 2011 09:53:47 Miroslav Zografski replied:
Hello Chris,

Actually displaying the results in one line i.e. Name Surname is something that is set within the encoded js file.

Since you are not the first to ask for such a thing I would better set this as request for next update so a user could specify if the results to be on one or two lines.

Regards,
Replied 30 May 2011 10:36:58
30 May 2011 10:36:58 Chris Trace replied:
The change in the line display would be great - thanks

by the way - session variables die if you try and use them to filter the record by ID or username even if you add another query to the php insert page - maybe something in the js but no mention of session in the code so maybe not

agood clean hack is to:

1. build a seperate php page with the user query based on session
2. create a $var eg $username
3. include that page into the autocomplete.php page as
include('setuser.php');
4. edit the first $sql to include the WHERE clause
$sql = 'SELECT '.$fields.' FROM `'.$table.'` WHERE muusername = "'.$username.'"';
5. change the WHERE clause on the $f line to AND
$sql .= ' AND '.$f[0].' LIKE "';

the ajax look up menu then becomes filtered by the username as well as the set lookup fields which is very handy and doesn't mess with any of the javascript




Replied 31 May 2011 16:25:36
31 May 2011 16:25:36 Miroslav Zografski replied:
Hello Chris,

Thanks for your contribution.

Regards,
Replied 16 Sep 2012 18:48:22
16 Sep 2012 18:48:22 Andres Gonzalez Michaca replied:
The solution is really simple, you don't have to modify any code. The secret is create a VIEW in MySQL and CONCAT the Values you like to show in one line.
For me works so great I show Name, Second Name and Last Name in one line.

If you need to handle variables you can use the Chris Example, also you can add direct in the automplete script in the url, the variable ej. ...autocomplete-1.php?id=<?php echo $_SESSION['id'];?>' or $_GET['whatever'];

And Inside autocomplete-1.php

You declare a variable:

$colname = $_GET['id']; or $_GET['whatever'];

And for the rest use the Chris hack:
Just change the point number 4, there you can use the field of your DB
ej: ...WHERE field_id = "'.$colname.'"';

Hope helps
Andres
Replied 20 Dec 2012 22:33:22
20 Dec 2012 22:33:22 Matt Penn replied:
Andres - thanks for the solution. I needed to have more control over some different things inside the autocompleted results as well and utilizing a view did the trick. Thanks!

Reply to this topic