Jump to content

Recommended Posts

I want to have a drop down which then causes a pdf to display based on drop down value.

I have tried something like this - see attached

 

I know this won't work but have no idea where to go.  I tried php but can't seem to make it work on my server.

 

thanks for you help

 

 

Test10.htm

Link to comment
https://forums.phpfreaks.com/topic/297528-drop-down-to-display-pdf-file/
Share on other sites

  • 1 month later...

I don't know what you plan on loading the pdf file into. I used an iframe as an example.

If you wanted the whole page to open the pdf file you could just use:

document.location = selection;
<H3><B>My Notes</B></H3>
<select name="mymonth" id="mymonth">
<option value="" selected>Select Pdf File</option>
<option value="FF_Mar06.pdf">Mar 20</option>
<option value="FF_Mar13.pdf">Mar 13</option>
<option value="NotAvail.pdf">Mar 06</option>
</select>

<script type="text/javascript">

var pdfSelect = document.getElementById('mymonth');

pdfSelect.addEventListener('change', function() {

	var selection = this.options[this.selectedIndex].value;
	var frame = document.getElementById('pdf_frame');
    frame.src = selection;
	
});

</script>
<br />
<iframe id="pdf_frame" src="" width="100%"></iframe>

</body>
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.