By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,043 Members | 1,275 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,043 IT Pros & Developers. It's quick & easy.

Macro substitution in Javascript

100+
P: 110
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.otherwebsite.com?name=<whatever 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?
Sep 9 '08 #1
Share this Question
Share on Google+
4 Replies


acoder
Expert Mod 15k+
P: 16,027
If the ID of the text box is "Producer":
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("Producer").value
Sep 10 '08 #2

100+
P: 110
If the ID of the text box is "Producer":
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("Producer").value
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.
Sep 10 '08 #3

gits
Expert Mod 5K+
P: 5,390
please show the html-code for your form where the textbox in question is located ...

kind regards
Sep 10 '08 #4

acoder
Expert Mod 15k+
P: 16,027
I think I've realised what you've done. You've put it all inside the string instead of putting the value outside:
Expand|Select|Wrap|Line Numbers
  1. "http://www.otherwebsite.com?name=" + document.getElementById("Producer").value;
Sep 10 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.