•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 430,112 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,211 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 917 | Replies: 2 | Solved
![]() |
•
•
Join Date: Jan 2008
Posts: 11
Reputation:
Rep Power: 1
Solved Threads: 0
Hi
The following code is part of a program i have written:
for (var count = 1; count <= password.length-2; count = count + 1)
{
document.write('*')
};
What i want is for the output of the above (which would be a number of characters the password is minus 2 shown in *) to not be written to the screen but to be added as a value to a variable.
Obviously document.write puts it on the screen. I want to be able to assign it to a variable, say 'code' and then i can use this elsewhere in my program.
Anyone know of a way.
Cheers
The following code is part of a program i have written:
for (var count = 1; count <= password.length-2; count = count + 1)
{
document.write('*')
};
What i want is for the output of the above (which would be a number of characters the password is minus 2 shown in *) to not be written to the screen but to be added as a value to a variable.
Obviously document.write puts it on the screen. I want to be able to assign it to a variable, say 'code' and then i can use this elsewhere in my program.
Anyone know of a way.
Cheers
•
•
Join Date: Apr 2004
Location: Brownsville or Austin, TX or Faber, VA
Posts: 59
Reputation:
Rep Power: 5
Solved Threads: 2
I haven't tested it out but you can try this am assuming this is what you are asking.
You could then just call the function to assign the string to whatever. I think you could even print it straight.
I repeat I haven't tested anything.
javascript Syntax (Toggle Plain Text)
function getCode(password){ var code=""; for(var count=1; count<=password.length-2;count++){ code+="*"; } return code; }
You could then just call the function to assign the string to whatever. I think you could even print it straight.
javascript Syntax (Toggle Plain Text)
document.write(getCode(theVarYouCalledPassword));
The purpose of my existence is why I am here.
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
ajax asp cross-browser javascript menu with few lines of code developer development firefox home html internet javascript javascript smooth scrolling scroll smoothly window document position javascript tab menu with rounded corners generator microsoft msdn office prevent javascript menu from getting hidden under flash movies site software sql vista web you tried to assign the null value to a variable that is not a variant data type
- trouble with double linked list (C++)
- how to delete some text from a txt file?? (C++)
- Suggests and solution to Histogram program problem please (C++)
- Permuttations (C++)
- I think Loop problem (Java)
- Record Files (Pascal and Delphi)
- How do I create a program using an Array ? (C++)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: two scripts beat as one
- Next Thread: IE6 oddity, looking for workaround


Linear Mode