Jump to content

Nektar

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by Nektar

  1. No problem i understand. In my case there will be indeed a lot of children. So i will look for the ajax solution. Thanks a lot for your help! I'll work on it and i will see what i can do!
  2. Yes i thought that would be the problem :/ .. I can't see how i will be able to do it with javascript because i need to call getRandom (as far as i know on how to work on stuff like that, and cause of that i will need php) but i find the ajax solution more logical maybe. Can you provide some code of a url which can help me? Because i am still in the learning process. Thanks a lot though!
  3. Hey, I would like to give me your help. In a project i am working on i am trying to build a slot machine. I am stuck at the point where everytime i click the button, so the reels will spin, i want it to give me a number of random children of a parent. Therefore i used getRandom(3), which is called with an onclick event, and does what it does in <script> tags in the php file. The problem is that it produces 3 random pages only one time. I want it everytime i click the button to find me new random children. So this is the code where is tries to Get the Random children: <script> function fillfirst(){ <?php $i=0; foreach ($get_md->children->getRandom(3) as $md) // here i take 3 random children of parent page { if($i==0){$a=$md->image->url;} elseif($i==1){$b=$md->image->url;} // here i put each child's image a else{$c=$md->image->url;} $i++; } ?> newreels = ['<?php echo $a;?>','<?php echo $b;?>','<?php echo $c;?>']; // here is the reel with the url of the images i want to have // but only at one specific click. Every new click i want the getRandom() // to give me new random children. document.getElementById("freel").innerHTML= '<div><img src="' + newreels.join('"></img><img src="') + '"></img></div><div><img src="' + newreels.join('"></img><img src="') + '"></img></div>' return newreels; } </script> And here is the code where it is called from (inside the html): <button class="w3-button w3-hover-yellow" onclick="fillfirst();">Main</button> If anyone has an idea it would be really helpful.
×
×
  • Create New...