w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Integrating js randomizer that displays results that can be styled with css.
This shouldn't be very complicated. Here's a really basic JSFiddle to play around with: http://jsfiddle.net/gUq7B/ For the HTML we have 3 paragraph tags that we'll use to show the dice. These could be div's or images or anything else you'll end up using on your site. <p id="dice1"></p> <p id="dice2"></p> <p id="dice3"></p> Next we'll want to declare our random variables using Javascript (I have 3 separate variables for simplicity but in production you may want to create a function to product the random number): var dice1rand = Math.floor((Math.random()*6)+1); var dice2rand = Math.floor((Math.random()*6)+1); var dice3rand = Math.floor((Math.random()*6)+1); Then we can set the paragraphs to display the values: document.getElementById("dice1").i

Categories : Java

JQuery string 'randomizer' clustering characters
This line is your culprit: if((Math.floor(Math.random() * 2) == 0) && numCount < 3 || charCount >= 5) { It says: The first 3 characters have a bit over 50/50 chance of being numbers. The "then" is always a number and the "else" is a number sometimes depending on options. After you have 5 "else" selected chars (which means after col 8), you will always have a number. This is because the "&&" takes precedence over the "||". I suggest using some parentheses to surround the OR clause if you want to have a 50/50 plus chance of using the digit. I also included an alternate way to do 50/50. if ((Math.random() < 0.5) && (numCount < 3 || charCount >= 5)) { I'm not sure why you want numbers to have precedence.

Categories : Javascript

How to format PHP querystring like time:bgcolor:fgcolor?
Just use $_SERVER['QUERY_STRING'] and parse as you need. For example $args = explode(':', $_SERVER['QUERY_STRING']); $format = $args[0]; $fgcolor = $args[1]; $bgcolor = $args[2];

Categories : PHP

jQuery bgColor animation: keep active when going down a sub-menu
I think you just need to change your selector so that the mouseleave event will only trigger once you have left the parent li: $('#nav-1 > li').hover(function(){ $(this).stop().animate({backgroundColor: '#FFF'}, 'slow'); }, function(){ $(this).stop().animate({backgroundColor: 'transparent'}, 'slow'); }); Here's a fiddle If you only want the animation to occur on the parent (the li or the span), you'd have to do something a little more elaborate: var $el, $this; $('#nav-1 > li').hover(function() { $this = $(this); $el = ($this.has('ul.sub-menu').length) ? $this.find('ul.sub-menu').prev() : $this; $el.stop().animate({ backgroundColor: '#FFF' }); }, function() { $el.stop().animate({ backgroundColor: 'transparent' }); }); So chec

Categories : Jquery

Javascript Changing bgColor Compatible Issue in IE 9? (no JQuery) (no console.log)
I'm not sure what getObjectById is doing, but you should be setting style.backgroundColor on your HTMLElement rather than the bgColor property. The bgColor property matches with the attribute of the same name, and this attribute has been depreciated since HTML 4.01 and obsolete in HTML5. elm.style.backgroundColor = '#CCCCFF';

Categories : Javascript

Placing an input-field in a label, changing bgcolor on focus
if I well understood try simply input:focus { position: relative; z-index: 1; } so, when the input is focused it will cover the label. Anyway you will see the label again when the input loses its focus. Probably you could obtain the right behaviour simply using the placeholder attribute

Categories : HTML

How to use a javascript Randomizer script to link into an iframe so that i can open from a list of links in the script
If I understand correctly, you want to load the URL in an iframe, and show the chosen URL somewhere on the website. Change your function to: <script type="text/javascript"> var url=[ 'http://www.fallingfalling.com', 'http://www.omfgdogs.com', ]; window.onload=function() { var theURL = url[Math.floor(Math.random()*url.length)]; document.getElementById('trig').onclick=function() { location.href=theURL; }} document.getElementById('chosenURL').innerHTML = '<a href="'+theURL+'">'+theURL+'</a>'; </script> Then add this HTML to your page, there where you want the text: <div id="chosenURL"></div>

Categories : Javascript

Trying to have both stylize() randomly select cell bgcolor and text style separately using CSS style
If I understood correctly, you are not being able to change the background correct? You need to fix the following CSS styles: .myBackground1{color:blue} .myBackground2{color:red} etc... with .myBackground1{background-color:blue} .myBackground2{background-color:red} etc... and change the code: function stylize() { if (index > 20) index = 1; var s = "myStyle" + index; var e = document.getElementById("MessageText") e.className = s { var bgindex = 0; bgindex++; if (bgindex >5) bgindex =1; var b ="myBackground" + bgindex; var c = document.getElementById("MessageCell") c.className = b } } with function stylize() { index = getRandomInt(1, 20); var s = "myStyle" + index; var e = document.getElementById("MessageText") e

Categories : Javascript

© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.