Passing a JavaScript variable as the src of an EMBED

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • polymorphic
    New Member
    • Oct 2006
    • 28

    Passing a JavaScript variable as the src of an EMBED

    I am no longer good at Javascript and need help. I'm trying to embed pdf files in html then build some sort of navigation between the pdfs via the pdf numbered file name.

    I can generate the javascript functions to extract and manipulate strings, ints, etc but can't seem to deal with the variables I produce.

    For instance, if current embedded pdf filename is "1.pdf" and button "Next" is clicked then embed "2.pdf". I cannot seem to get the logic for generating the variable to change the pdf filename. I suppose that I can store a variable in a hidden textbox or an iframe but I do not know how to get the variable back out to insert into the html that will embed the pdf.

    Say I have a text box as so:[code=html]
    <INPUT TYPE = "hidden" name = "currentPag e" value = variableA ID="Hidden1">[/code]

    how do I populate and get variableA out and put it into my embed tag:
    [code=html]
    <embed> src = "variableA" </embed>[/code]

    [Please use CODE tags when posting source code. Thanks! --pbmods]

    any help is appreciated.

    cj
    Last edited by pbmods; Jul 19 '07, 10:23 PM. Reason: Added CODE tags.
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Changed thread title to better describe the problem.

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Get the value of the hidden field by using, e.g.
      Code:
      var variableA = document.getElementById("Hidden1").value;
      Give the embed tag an id and set the src property using
      Code:
      document.getElementById(embedID).src = variableA;

      Comment

      Working...