|
Posted by Jerry Stuckle on 07/07/06 11:36
Robert S wrote:
>>Why are you even passing the filename in a button's name?
>>
>>Why not:
>>
>> <form action=test.php method=post>
>> <div>
>> <input type=hidden name=myfile value="filename.txt">
>> <input type=submit>
>> </div>
>> </form>
>
>
> The page is a fax client that allows large numbers of files to be faxed
> off to multiple recipients. I have a whole lot of buttons and text
> inputs that refer to different files. The receiving page loops through
> $POST and identifies the file that the button refers to. All text
> inputs and checkboxes etc need to be sent to the receiving page, so I
> can't use multiple <form> elements. The example I gave was just an
> illustrative example - its not from my code. As far as I can see this
> seems to be the only way of doing it. The files are .PDF files created
> by cups-pdf - so they are FULL of underscores. If I use an <a href>
> tag, the POST variables don't get sent to the receiving page.
>
> bin2hex looks like the way to go.
>
OK, no problem. Just:
<form action=test.php method=post>
<input type=hidden name="filename[0]" value="filename.txt">
<input type=submit name="Submit[0]">
<input type=hidden name="filename[1]" value="filename.pdf">
<input type=submit name="Submit[1]">
<input type=hidden name="filename[2]" value="filename.doc">
<input type=submit name="Submit[2]">
<input type=hidden name="filename[3]" value="filename.html">
<input type=submit name="Submit[3]">
</form>
File names are in $_POST['filename[0]'], $_POST['filename[1]'], etc.
The button which was pressed will be in $_POST['Submit[x]'].
Simply loop through the Submit array to find which one was pressed with
isset(), and pick the appropriate file from the filename array.
Expandable, easily programmed and requires no JS.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|