javascript - Build a Form with 2 dropdown options that load a specific PDF -
I think there may be something that has already been answered and I apologize if it is, So I did not get it.
What I need to do is build a simple form, which has two options, they are dropdown options. I understand this part in the dropdown a and dropdown bub Submit button HTML, although it can be easy in PHP or Javascript.
Then I need to take two options and prepare a "if / then" statement that loads a specific PDF which two options are selected.
Example. If a dropdown selects option 1 from dropdown b from A and option 2, then it loads 12.pdf if someone selects option from dropdown b in A dropdown A and option 3 then it load 53.pdf if a person Selects Option 2 from the dropdown A and option 1 by dropdown B then it loads 21.pdf
and so on ...
Thanks for any help.
Additional Here is my current HTML form script
end lieutenant; DOCTYPE HTML PUBLIC "- // W3C // DTD XHTML 1.0 Transcription // N" "http://www.w3.org/ TR / xhtml1 / DTD / xhtml1-transitional.dtd" & gt; & Lt; Html xmlns = "http://www.w3.org/1999/xhtml" & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" /> & Lt; Title & gt; Untitled document & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Center & gt; & Lt; H1 & gt; Get directions & lt; / H1> & Lt; Form action = "results.html" method = "go" name = "directions" target = "_new" & gt; & Lt; Select name = "start" size = "1" & gt; & Lt; Option value = "Answer" & gt; North Tower Entrance & lt; / Option & gt; & Lt; Option value = "south" & gt; South Tower Entrance & lt; / Options & gt; & Lt; Option value = "mba" & gt; Mob A entrance and lieutenant; / Options & gt; & Lt; / Select & gt; ----- & gt; & Lt; Select name = "end" size = "1" & gt; & Lt; Option value = "onco" & gt; Oncology & lt; / Option & gt; & Lt; Option value = "radio" & gt; Radiology & lt; / Option & gt; & Lt; Option value = "punm" & gt; Pulmonary & lt; / Option & gt; & Lt; / Select & gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; Input name = "submit" type = "submit" value = "submit" /> & Lt; / Form & gt; & Lt; / Center & gt; & Lt; / Body & gt; & Lt; / Html> gt; Looking at this code I need to call a specific PDF which will represent a combination of options. Thank you.
function getFileName (select1Id, select2Id) {var sel1 = document.getElementById (select1Id); Var sel1Index = sel1.selectedIndex; Var sel2 = document.getElementById (select2Id); Var sel2Index = sel2.selectedIndex; If ((sel2Index + sel1Index) === 0) {return ""; } Return sel1Index.toString () + sel2Index.toString () + '.pdf'; }
You can pass the unique ID of your combo box in the above task and it will provide you the related PDF file name. Name is empty if this blank comes back
You can call the above function from the event handler on your button, get the name of the file and can load it on the web page.
- I have not made legalization, which you can add
Hope it helps
Comments
Post a Comment