1 (edited by pm 2020-09-19 08:48:32)

Topic: add download link on click result

Hi

here is the setup

I have a searchbox to fetch a zip file by number

then, get the result list in results box

i would need to edit database to get that with on clic on the result line that it downloads the zip file from my server




anyone with a Idea  how ?

thank you !

Post's attachments

Attachment icon ffffffffffff.PNG 2.25 kb, 138 downloads since 2020-09-19 

2

Re: add download link on click result

more picture

Post's attachments

Attachment icon ddddd.PNG 20.51 kb, 132 downloads since 2020-09-19 

3

Re: add download link on click result

I added a new field in the database with the download link

now I guess that I should use the OnCellDoubleClick function
but what would be the parameter to pull the Database Id cell's download link cell ?

4

Re: add download link on click result

also,  all files come from same link and have same name as shower in the text colum

so maybe its possible to add something in the script that will add automaticly http://www.mywebsite.com/ before the file name
so I don't have too long lines in the database

5 (edited by CDB 2020-09-19 21:21:51)

Re: add download link on click result

In answer to your last question PM, that is quite easy to do.


Below I'm using a label to display a URL on a form and the label has got the URL from a database field. I then click on the label to open a webpage.

procedure frmMain_lbWebpage_OnClick (Sender: TObject);
var
    webpage:string = 'http://www.mywebsite.com/'; {assign fixed text to a string}
begin
  
  webpage := webpage + frmMain.lbWebpage.Caption; { add the database information to the existing string}
  OpenURL(webpage); 
end;

Obviously you don't have to use a display label as I have, you could just use another string variable to contain the database information or a hidden text box.

frmMain.lbWebpage.Caption := sqlexecute('SELECT suppliers.webpage FROM suppliers where id =' +frmMain.tgSuppliers.sqlvalue);

Substitute frmMain.lbWebPage.Caption with a local string variable if you wish.


There are a few variations on the way you could use variables and or constants to this theme.

On a clear disk you can seek forever

6

Re: add download link on click result

thank you !

7

Re: add download link on click result

sorry I can't get it working

may I get some more help please ?

Re: add download link on click result

What is or isn't the above code doing for you?


Could you either provide and example of your script or better still an example of your project.


You did change my form and component names to your names?

On a clear disk you can seek forever

9

Re: add download link on click result

CDB wrote:

What is or isn't the above code doing for you?


Could you either provide and example of your script or better still an example of your project.


You did change my form and component names to your names?


I didn't get it how to use your code

if you would be so kind and make me a example, the I would understand
sorry

so to be clear
I have a long list of names in the database
in a search box, you can type numbers
and in the large text box you'll get all names that fit to what you search

now as all files are in the same only folder on the http server
it could be as simple as:  for download pull the file name and add http  hmm/mydomain.com  before

double click and it downloads

thank you very much for your kindness !

10 (edited by CDB 2020-09-23 04:54:59)

Re: add download link on click result

Does the attached project help?

It is very basic and as it stands you can click on the table grid and get the link to open even with out entering a reference number.  if you enter number 1,2 or 3 into the search box it will automatically display just that entry.

However that can be fixed.

If you didn't want to see the actual link you can just not show that column and change the column number in the script to 1


I've just realised I've done it as a single click, all you need to do is copy the code to the double click event and delete the single click procedure.

Post's attachments

Attachment icon for PM.zip 337.1 kb, 295 downloads since 2020-09-23 

On a clear disk you can seek forever

11 (edited by pm 2020-09-23 20:26:43)

Re: add download link on click result

CDB wrote:

Does the attached project help?

It is very basic and as it stands you can click on the table grid and get the link to open even with out entering a reference number.  if you enter number 1,2 or 3 into the search box it will automatically display just that entry.

However that can be fixed.

If you didn't want to see the actual link you can just not show that column and change the column number in the script to 1


I've just realised I've done it as a single click, all you need to do is copy the code to the double click event and delete the single click procedure.



Thank you very much for all your help !

I tried and nearly succeed but after I tried again I didn't end up with success

Problem is that I have no integer,  and want one colum only

file names are made from letters, underscore, dots and numbers as in test database
search works great

I pasted you my project here so maybe you would be kind enough to integrate your download function

I uploaded the listed test files on server and pasted the http ip in the script  so you can test it

thank you, you are great !

12

Re: add download link on click result

it seems my server has still some issues   please use your own test location if it doesn't work
sorry

13

Re: add download link on click result

PM, I'm a little confused, in your database you have just the one field - file.


So, will you be searching using just the file name or is there going to be some other column such as person name or person number?

On a clear disk you can seek forever

14

Re: add download link on click result

CDB wrote:

PM, I'm a little confused, in your database you have just the one field - file.


So, will you be searching using just the file name or is there going to be some other column such as person name or person number?


no no
just one colum with the file name

that's it
nothing else

thx !

15 (edited by CDB 2020-09-24 10:12:38)

Re: add download link on click result

Updated script.

Post's attachments

Attachment icon pm_test.zip 979.41 kb, 327 downloads since 2020-09-24 

On a clear disk you can seek forever

16

Re: add download link on click result

CDB wrote:

Updated script.

that works !

thank you so much

17

Re: add download link on click result

CDB wrote:

Updated script.

project done !  perfect
thank you VERY much for your patience and help !