Search the Community

Showing results for tags 'getrandom()'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • ProDrafts
  • ListerPro
  • ProFields
  • ProCache
  • Form Builder
  • Likes
  • ProDevTools
  • Custom Development


There are no results to display.

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL







Found 1 result

  1. 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.