Macro substitution in Javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • andersond
    New Member
    • Feb 2007
    • 110

    Macro substitution in Javascript

    I need to pass the value of a textbox in a call to another URL. I have a form with a textbox named "Producer." I need to send the value typed into that text box to another site, eg: "http://www.otherwebsit e.com?name=<wha tever has been typed into the "Producer" textbox>"

    What I am getting passed now is the literal value of whatever is to the right of the equals sign in "name=".

    How can I pass the value of the textbox instead of the name of the textbox?
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    If the ID of the text box is "Producer":
    [code=javascript]document.getEle mentById("Produ cer").value[/code]

    Comment

    • andersond
      New Member
      • Feb 2007
      • 110

      #3
      Originally posted by acoder
      If the ID of the text box is "Producer":
      [code=javascript]document.getEle mentById("Produ cer").value[/code]
      I've already tried that. I've tried putting that exact code in the line calling the url and I've tried using that exact code to define a variable and use it in the line calling the url. It doesn't work. I still get whatever I put in the line that calls the url.

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        please show the html-code for your form where the textbox in question is located ...

        kind regards

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          I think I've realised what you've done. You've put it all inside the string instead of putting the value outside:
          [code=javascript]"http://www.otherwebsit e.com?name=" + document.getEle mentById("Produ cer").value;[/code]

          Comment

          Working...