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

Textbox variable help

P: 1
I am a beginner and would like to know how to make the variable "add" something you input into this script via a textbox. Any help would be much appreciated. Thanks.

Expand|Select|Wrap|Line Numbers
  1. function replaceChars(entry) {
  2. out = "xxxx"; 
  3. add = "z"; // I don't want z to be "add," I want that to be user inputted
  4. temp = "" + entry;
  5.  
  6. while (temp.indexOf(out)>-1) {
  7. pos= temp.indexOf(out);
  8. temp = "" + (temp.substring(0, pos) + add + 
  9. temp.substring((pos + out.length), temp.length));
  10. }
  11. document.subform.text.value = temp;
  12. }
  13.  
Feb 23 '07 #1
Share this Question
Share on Google+
1 Reply

acoder
Expert Mod 15k+
P: 16,027
Declare a text input in a form:
[HTML]<form id="myform" ...>
<input type="text" id="mytext" name="mytext" value="">[/HTML]
then access it using
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("mytext").value
Feb 23 '07 #2

Post your reply

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