Skip to content

Tag: html

PHP/JavaScript random number

I am playing around with JavaScript and trying to choose some random images. What I’m actually trying to do: I have $totalsixes = rand(1,6); in PHP, and let’s say that chose 4. Then in JavaScript I want to show 4 images with the number 6 and 2 others with random numbers from 1-5. Here’s what…

Open Base64 in new tab

I have a Base64 encoded document which can be PDF file or image. I would like to create a button in HTML5 page that opens this base64 in a new tab (or new page it does not matter) I found this code can do the trick : It works well. But when I replace the http link with then the

Start and stop with keypress from keyboard

I have this JavaScript http://jsfiddle.net/ZDsMa/433/ to pick a random number. I put this on html div and I want to start scrambling the numbers with keypress instead of onClick, also to stop again with keypress: Answer You can wrap the animation in a function and then call it on keypress… something lik…

Get ID from “ tag using a combined `.match` call

I have a string like this And I just want to get the id value which is test_name. I use this code: Is there any other ways to combine two match calls into one? Answer Use capturing group. If the regular expression contain capturing group, String.prototype.match will return an array which contains whole matche…