/    Sign up×
Community /Pin to ProfileBookmark

loops and document.write

I am having problem with the loop and document.write. The code worked befor I added the loop. Im trying to get the script to print the number that is in the

[COLOR=red]url[/COLOR] which is the last character in the url and print it that many times. Example if the number is 2 print 2 and print it twice.

<form name=”form1″><input type=”hidden” name=”lettersfromurl” size=”35″></form>
<script language=”javascript”>
var urlnumbers = window.location
document.form1.lettersfromurl.value = urlnumbers
var text = document.form1.lettersfromurl.value
var yourSent = getnumbers.value;
function getnumbers(str){
looktotheright = str.lastIndexOf(“?”) +1;
return(str.substring( looktotheright));
document.write(“you sent ” +getnumbers(text));
for (i = 0; i < youSent; i++)
document.write( i + ” ” + yourSent + “<BR/>”);
}
</script><br>

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@jaegernautApr 15.2004 — In your for loop you left the "r" out of your variable name.

Using youSent vs. yourSent.

I don't know if that was a typo on the post or is actually in your code.
Copy linkTweet thisAlerts:
@gogotinaauthorApr 15.2004 — Just a dumb typo. I corrected this and the page is still blank. I think it has to do with the placement of the loop maybe?
Copy linkTweet thisAlerts:
@steelersfan88Apr 15.2004 — make an ongoing string in the loop, and write it once outside the loop
Copy linkTweet thisAlerts:
@steelersfan88Apr 16.2004 — did you get it to work?
Copy linkTweet thisAlerts:
@gogotinaauthorApr 17.2004 — Yes it works well, I like how you just doint give the answers. It is good that you tell what is wrong and make us go from there. Thnx........
Copy linkTweet thisAlerts:
@steelersfan88Apr 17.2004 — normally people rather like the answers, but time constraints have caused me not to be able to do that as much; however, if you needed a demo, I would certainly have found time for it ?
×

Success!

Help @gogotina spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...