ozalkl Posted April 12, 2010 Share Posted April 12, 2010 how would i able to tell the submit button when clicked to grab the pdf file based on the selections? and how do i grab the selection name? for example: Form name "pdf" selection 1: i choose A selection 2: i choose B selection 3: i choose C when hit "submit" button, should call ABC.pdf i would really appreciate if anyone can help me with this part of the code or any tutorials based on the above Link to comment https://forums.phpfreaks.com/topic/198288-call-pdf-file-when-click-submit-button-in-a-form-based-on-selections/ Share on other sites More sharing options...
andrewgauger Posted April 12, 2010 Share Posted April 12, 2010 <form action="pdfHandle.php" method="post"> <Select name="docName[]"> <option name="a">a <option name="b">b <option name="c">c </select> <Select name="docName[]"> <option name="a">a <option name="b">b <option name="c">c </select> <Select name="docName[]"> <option name="a">a <option name="b">b <option name="c">c </select> </form> pdfHandle.php <?php $docName=$_POST["docName"]; $location= implode("",$docName).".pdf"; Header("Location: $location"); exit(); ?> You might want to also just print a link to the pdf to open in a new window instead: <?php $docName=$_POST["docName"]; $location= implode("",$docName).".pdf"; echo "<a href=\"$location\" target=\"_blank\">Your pdf is available</a>"; ?> BUT this is not the way I would do this. This means you need to have 9 pdf documents always available. Better would be a single drop down box that reads contents from a MySQL database. To each their own. Link to comment https://forums.phpfreaks.com/topic/198288-call-pdf-file-when-click-submit-button-in-a-form-based-on-selections/#findComment-1040439 Share on other sites More sharing options...
ozalkl Posted April 12, 2010 Author Share Posted April 12, 2010 thank you, i will implement using this method, i've already created all possible selections in diff pdf, so i think doing it this way wouldn't make issues since the pdf's are already created with all sort of selection options. is there anything else shall i address to have this method working? additional coding or scripts to run along this method? Link to comment https://forums.phpfreaks.com/topic/198288-call-pdf-file-when-click-submit-button-in-a-form-based-on-selections/#findComment-1040451 Share on other sites More sharing options...
andrewgauger Posted April 12, 2010 Share Posted April 12, 2010 It should be complete. I haven't tested it though, so let me know if there are errors. I designed it so you can dynamically add fields. such that if you needed to make it ABCD.pdf all you have to do is copy and paste the select& options. Link to comment https://forums.phpfreaks.com/topic/198288-call-pdf-file-when-click-submit-button-in-a-form-based-on-selections/#findComment-1040463 Share on other sites More sharing options...
ozalkl Posted April 13, 2010 Author Share Posted April 13, 2010 i tested it, it works great, i altered my selection coding to match the php function, i just have one last question, how do i call the location of the pdf file. i mean currently its abc.pdf what if i want it to be in this folder "pdfs/abc.pdf" Link to comment https://forums.phpfreaks.com/topic/198288-call-pdf-file-when-click-submit-button-in-a-form-based-on-selections/#findComment-1041000 Share on other sites More sharing options...
andrewgauger Posted April 13, 2010 Share Posted April 13, 2010 Thanks, glad it works. All you would have to do is modify the $location variable to what the directory should be: <?php $docName=$_POST["docName"]; $location= "pdfs/".implode("",$docName).".pdf"; Header("Location: $location"); exit(); ?> Link to comment https://forums.phpfreaks.com/topic/198288-call-pdf-file-when-click-submit-button-in-a-form-based-on-selections/#findComment-1041100 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.