4
Contributors
9
Replies
11
Views
5 Years
Discussion Span
Last Post by diafol
0

In the second situation use two div elements each containing the form elements for one radio button and one div being visible (display:block) and other hidden (display:none). Radio buttons should have JS code which is fired on onclick event and toggles the visibility of both div elements.

Edited by broj1: n/a

0

To try to help with first question: onclick event can call only javascript function (I think) so you can write one and use window.open('./downloads/') javascript built in method or window.location='./downloads/'.

Edited by broj1: n/a

0
onClick="./downloads/'

I can't understand what that does either. onclick should run js code - either inline code inside the attribute itself or a call to a js function (usually placed in the head section of the html page).

Forgive my ignorance, but this output looks overly complicated:

<h3><?php echo mysql_result($result, 0, "Name");?></h3>
<form>
<p><input type="button" value="Download" onClick="...some js...<?php echo mysql_result($result, 0, "Link");?>"></p>
</form>

That would be more readable when it comes to debugging etc. Or even:

<?php
  $var1 = mysql_result($result, 0, "Name");
  $var2 = mysql_result($result, 0, "Link");
?>
<h3><?php echo $var1;?></h3>
<form>
<p><input type="button" value="Download" onClick="...some js...<?php echo $var2;?>"></p>
</form>

I still can't work out what the second var does. Does it append a bit of url to the downloads directory?

As broj1 states, you need to use a js redirect if this is the functionality you're looking for. OR, you can enter this url to the form action attribute and set the button click to submit.

BTW - do you really need to use mysql_result? It's slow and there could be better functions to use to retrieve data from a result object.

Edited by diafol: n/a

0

To try to help with first question: onclick event can call only javascript function (I think) so you can write one and use window.open('./downloads/') javascript built in method or window.location='./downloads/'.

Well, I'm not trying to open the download folder, what I am trying to do is when the user clicks on the button the corresponding file download window pops-up

I still can't work out what the second var does. Does it append a bit of url to the downloads directory?

As broj1 states, you need to use a js redirect if this is the functionality you're looking for. OR, you can enter this url to the form action attribute and set the button click to submit.

The $var-s actually link to a database where there is a column with "Name" (name of the file, which appears for the user before downloading) and "Link" (the actual location of the file recorded in the database). These two variables indicate what corresponding file to download from a folder by use of the database. I hope this clarified a little what I'm trying to do.

BTW - do you really need to use mysql_result? It's slow and there could be better functions to use to retrieve data from a result object.

The problem is that I didn't actually develop this web system. It was developed by someone else, all I am doing is adding some new features. I actually don't want to rebuild the whole system just because of the slow query result fetching. Besides, the whole system is on LAN, so the speed is not that important.


Now, to make it more understandable, what I'm trying to do is just change the hyperlink (like this) into a button, but the function of the link is just a simple download. I have to mention that I'm not that good at web-programming, my main concentration is high-level programming languages like C/C++, Java and so on, but I was asked to help out to do some minor interface changes, so I agreed.

0
<a href="./path/to/some/file/to/download.pdf"><button name="" id="">Download</button></a>

Am I missing anything about the complexity or functionality of this?

0

PHP Syntax (Toggle Plain Text)

<a href="./path/to/some/file/to/download.pdf"><button name="" id="">Download</button></a>


Am I missing anything about the complexity or functionality of this?

The problem is that each file has a long name like SvrEncrptHashChk.pdf and alike, and the missing part is that I don't want to hard-link every file to a link because there are more than 200 files in that folder. The previous hyperlink did a sort by name and let the user download the corresponding file according to 2 parameters, which are the "Name" and "Link" cause these 2 are like unique keys in the database

EDIT: The 1st attached file shows the picture of how it look now.

The 2nd attachment shows the page which appears before actual download page does.

Edited by KillingKiller: Edit:

Attachments 1.jpg 87.94 KB 2.jpg 55.79 KB
0

you can loop these via php - you don't have to hard code anything.

have an array of filenames
set up a loop to print a filename/link/button from the array on each iteration

Edited by diafol: n/a

0

you can loop these via php - you don't have to hard code anything.

have an array of filenames
set up a loop to print a filename/link/button from the array on each iteration

If i understood you correctly, then do you want me to print all of the file names in the folder?

0

NO. You can get all the filenames from a simple file in directory iteration or if you have certain filenames in mind, just place them into an array.

loop the array, extract the filename and place into some html on each iteration

standard stuff

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.