Contentful logo

Contentful Community

Loading PDF's from a drop down menu

#1

Hello! I’m trying to make a drop down list that will display the names of various forms. I want to be able to load the pdf’s when the name is clicked. Currently, I can tell that the site is aware that there are 4 items in the menu, but it just shows 4 blank spaces. And clicking them does nothing. On the Contentful side, I have a content type called HRForms, with two fields - title, a short text field - and formName, which is a Media type to hold the PDF’s. Here is the code in HTML:

    <select>
    @foreach (var form in Model)
    {
        <option value ="@form.Title"></option>
    }
</select>
0 Likes

#2

Hey @appdev!

If I understood your usecase correctly, media should be created to serve many media files (Many files option when configure the field) and you need to call the entry like this https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/entries/entry (you can switch to JavaScript to see the snippet).
As for handling/rendering it in HTML, I’m not an expert in HTML but this might help https://www.w3schools.com/howto/howto_js_dropdown.asp.

Let me if that sheds some light. If it doesn’t I’ll try to find a way provide you with more details and some suggestions regarding this.

0 Likes

#3

As far as I know, do the thing like this one requires a hell of a code to write. I can’t do so by myself, to be blunt, but I think you should take a look on the example of the code written for this tool https://4000a-125-2-form.pdffiller.com/ it has this feature you requested as well, but I guess it will take some time to figure something out with this. It’s a paid solution, but you can get some free trial period and go through that code

0 Likes