Home | Community | Message Board


This site includes paid links. Please support our sponsors.


Welcome to the Shroomery Message Board! You are experiencing a small sample of what the site has to offer. Please login or register to post messages and view our exclusive members-only content. You'll gain access to additional forums, file attachments, board customizations, encrypted private messages, and much more!

PhytoExtractum Shop: Maeng Da Thai Kratom Leaf Powder

Jump to first unread post Pages: 1
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
HTML, PHP or JavaScript ??
    #26664182 - 05/11/20 10:15 AM (3 years, 8 months ago)

I got this webpage that displays a whole bunch of "text area" boxes...

There yellow in back ground color.

HTML code is:
Quote:

<textarea name="party" cols="70" rows="12" maxlength="750" wrap="soft" class="party">
yo yo yo
</textarea>




and CSS is:

Quote:

.party {
    color: #4865C3;
    font-family: Consolas, "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", Monaco, "Courier New", monospace;
    font-size: medium;
    background-color: #FAFFCD;
    resize: none;





What i'm tryiong to do here is make these text boxes (areas) appear with a random back ground color, a pick of say 10 colors

Any ideas how to do this? Can you do this with HTML or you need javascript/PHP?


--------------------





Edited by Gypsy Boy (05/11/20 10:59 AM)


Extras: Filter Print Post Top
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
Re: HTML, PHP or JavaScript ?? [Re: Gypsy Boy]
    #26664274 - 05/11/20 11:11 AM (3 years, 8 months ago)

There’s a nice algorithm on stack overflow:




$background_colors = array('#282E33', '#25373A', '#164852', '#495E67', '#FF3838');

    $count = count($background_colors) - 1;

    $i = rand(0, $count);

    $rand_background = $background_colors[$i];



But how do I incorporate it into each text area/box or css ??

Should I ditch css and try to apply unique custom settings to style option of every text area?


Extras: Filter Print Post Top
Offlinesinglet_oxygen
Stranger
Registered: 05/10/20
Posts: 32
Last seen: 3 years, 6 months
Re: HTML, PHP or JavaScript ?? [Re: Gypsy Boy]
    #26664608 - 05/11/20 02:08 PM (3 years, 8 months ago)

You really need to try and solve programming problems to learn.

I'd prefer to solve this in javascript, here's a fiddle.

HTML, we use a class called foobar for elements which should have a random background.
Code:

<textarea class="foobar">
Foo
</textarea>
<textarea class="foobar">
bar
</textarea>
<textarea class="foobar">
Foobar
</textarea>



Javascript we define two functions, one makes random colours, one loops through every element with class foobar.
Code:

function randomColour() {
let r = Math.floor(Math.random() * 256);
let g = Math.floor(Math.random() * 256);
let b = Math.floor(Math.random() * 256);
return `RGB(${r},${g},${b})`;
}

function randombg() {
let tas = document.getElementsByClassName("foobar");
let elems = tas.length;
let i;
for(i = 0; i < elems; i++) {
tas[i].style.backgroundColor=randomColour();
}
}
randombg();




Make sure to call randombg() somewhere, maybe in body's onLoad.


I'd do it in javascript because it's purely aesthetic and it'll be easy to change which elements have class "foobar".

Unfortunately getElementsByClassName returns a HTMLcollection not an array, or code would be neater with a map.


--------------------
1O2


Extras: Filter Print Post Top
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
Re: HTML, PHP or JavaScript ?? [Re: singlet_oxygen]
    #26665764 - 05/12/20 04:29 AM (3 years, 8 months ago)

I removed < from php cos the forum wont allow me to post it

Thanx for helping again dude.

I just tried HTML / PHP version just for the heck of it ............. and it works!!!

?php
    $background_colors = array('#E19766', '#F1AECB', '#ABB4E0', '#ABE0BE', '#D4AC7F');

    $count = count($background_colors) - 1;

    $i = rand(0, $count);

    $rand_background = $background_colors[$i];
?>

All good.


Onto:

p style="background-color: ?php echo $rand_background; ?> ">Hmmmmmmmmmmmmmmmmm</p>

All good.

Hoefully it applies to the arera boxes well


--------------------





Extras: Filter Print Post Top
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
Re: HTML, PHP or JavaScript ?? [Re: Gypsy Boy]
    #26665779 - 05/12/20 04:44 AM (3 years, 8 months ago)

IT WORKS!!!!!!!!!!!!!!!!

No need for JAVA!!


:feelsgoodman::gethigh::lol::strokebeard::haha::blowjob:


--------------------





Edited by Gypsy Boy (05/12/20 05:38 AM)


Extras: Filter Print Post Top
OfflineGypsy Boy
Redeemer
Male


Registered: 03/17/17
Posts: 4,501
Loc: Deep in the discoteka
Last seen: 2 months, 25 days
Re: HTML, PHP or JavaScript ?? [Re: Gypsy Boy]
    #26665805 - 05/12/20 05:32 AM (3 years, 8 months ago)

OOhh Bay Baby Baby

Wont you feed me :awesome:

My shit works!!


--------------------





Extras: Filter Print Post Top
Jump to top Pages: 1

PhytoExtractum Shop: Maeng Da Thai Kratom Leaf Powder


Similar ThreadsPosterViewsRepliesLast post
* PHP NUKE RIPPING Genius 603 3 11/06/04 05:11 PM
by Ythan
* ATTN: PHP/MySQL Gurus
( 1 2 all )
elbisivni 2,075 20 09/04/07 06:04 PM
by elbisivni
* --- EntheogenicPeace 624 2 01/04/07 05:03 PM
by EntheogenicPeace
* php easter egg Mycomancer 5,143 7 05/02/06 03:15 AM
by Le_Canard
* HTML/CSS question dirtworshipper 608 2 01/24/22 05:46 PM
by SprewellSleeve
* PHP simple login elbisivni 1,372 4 06/04/07 04:40 AM
by Seuss
* Coders... I need a little javascript help! ilus 588 4 02/15/08 04:36 PM
by ilus
* my simple programming questions thread (javascript + html) stefan 716 3 04/28/08 04:43 PM
by stefan

Extra information
You cannot start new topics / You cannot reply to topics
HTML is disabled / BBCode is enabled
Moderator: trendal, automan, Northerner
366 topic views. 1 members, 2 guests and 0 web crawlers are browsing this forum.
[ Show Images Only | Sort by Score | Print Topic ]
Search this thread:

Copyright 1997-2024 Mind Media. Some rights reserved.

Generated in 0.021 seconds spending 0.004 seconds on 12 queries.