The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 23, 2019, 12:24:44 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: I am a crap coder  (Read 3493 times)
JasonD
Expert
****
Offline Offline

Posts: 100


View Profile
« on: July 13, 2007, 04:29:35 PM »

The title says it all really as I just dabble rather than program any more.

Anyway, I am dabbling with a bit of fun code atm and running a for loop within a for loop.

I want to add another loop in there with a timer working as a delay that will change the content of several iframes that have had their names dynamicaly assigned by the for loop.

How do I do it ?

Example code below and thanks for your help guys n gals.

Code:

<script>

for (r = 1; r < Multiplier; r++){


for(i = 1; i < AmountofViews; i++){
var url="http://www.XXXXXXXXXXX>XXX"+"&"+Math.random();
document.write('Viewing Number:'+i+'<iframe name = "framename'+i+'""src ="'+url+'"width="10" height="10"></iframe><br>');

}
// code here to pause browser to allow pages to load
// code here to reload iframes Multipler times
}
</script>
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #1 on: July 13, 2007, 04:43:03 PM »

The only thing worse than your coding is your explanations ROFLMAO

I want to add another loop in there with a timer working as a delay that will change the content of several iframes that have had their names dynamicaly assigned by the for loop.
Code:
<script>

for (r = 1; r < Multiplier; r++)
{
for (i=1; i < AmountofViews; i++)
{
var url="http://www.XXXXXXXXXXX>XXX"+"&"+Math.random();
document.write('Viewing Number:'+i+'<iframe name = "framename'+i+'""src ="'+url+'"width="10" height="10"></iframe><br>');
}

// code here to pause browser to allow pages to load
// code here to reload iframes Multipler times

}
</script>

OK - sounds to me like you're trying to dynamically add iFrames to the page at a random interval... yes?

First off - there is no "sleep" in JS - you cannot create a blocking call. Therefore, the way to do this is actually to set a random amount of time to a setTimeout() function which will call <the next iFrame function> in a random number of ms. Before I go deep, please tell me if I am on the right track and I can tell you how to do it.

Randomly changing ads, or perhaps ... hehehe... Wink
/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
JasonD
Expert
****
Offline Offline

Posts: 100


View Profile
« Reply #2 on: July 13, 2007, 04:52:53 PM »

I appreciate there is no pause function in JS, but I also think I can get to where I need to via something like

Code:
setTimeout("document.write('hello world')",1000);

You're not far off mate, but it aint ads it is......... *** OOOPS ME SHUTS UP BUT MIGHT EXPLAIN IF YOU TURN SKYPE ON ***

But I don't know how to change the Iframes named as in the example (and crap) code.
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #3 on: July 13, 2007, 05:03:22 PM »

I appreciate there is no pause function in JS, but I also think I can get to where I need to via something like

Code:
setTimeout("document.write('hello world')",1000);
Zactly right, although I personally do not care for document.write.

Quote
You're not far off mate, but it aint ads it is......... *** OOOPS ME SHUTS UP BUT MIGHT EXPLAIN IF YOU TURN SKYPE ON ***
Heh... thought so  Wink from whence you 'n me came, my imagination has no problems with where you might be. I'd turn on me SKYPE but unfortunately I am on my notebook right now and haven't set it up here - we had an air conditioning unit explode on us day-before-last and the spike (as it grounded itself) actually made it through my batteries and surge protector and took out my main Mac. It's in the shop now seeing if it is only a power supply. S'posen I should get skype going here...

Quote
But I don't know how to change the Iframes named as in the example (and crap) code.
Here is an interesting article - it actually talks about remote scripting using iFrames rather than ... um, well where you might be, but at the bottom is a rather fleshed out chunk of code that shows how to create and destroy iFrames dynamically and with strong support in virtually all browsers. Good reading. Here:

http://developer.apple.com/internet/webcontent/iframe.html

Ping back if that's not answering you.
/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
JasonD
Expert
****
Offline Offline

Posts: 100


View Profile
« Reply #4 on: July 13, 2007, 05:11:41 PM »

ping

lol Smiley
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #5 on: July 13, 2007, 05:16:33 PM »

 Roll Eyes

Awright ya bloody wanker.

PM me here with more crisp details please and lemmee see...

/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
JasonD
Expert
****
Offline Offline

Posts: 100


View Profile
« Reply #6 on: July 16, 2007, 02:01:19 PM »

Shit I am still a crap coder.

Why on earth don't I do this in Perl as it would take 10 minutes ?

I think the answer is cos I know it can be done in JS, the problem is I simply am crap lol
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #7 on: July 16, 2007, 02:33:47 PM »

What's the issue now?
Are you willing to post your code here?
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!