w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
JavaScript for multiple image change based on pc clock
The problem is that document.getElementsByTagName(...) returns a list of elements. Your code is selecting only the first one and setting the "img" variable to that one. Modify the "setInterval" function to handle an array instead of a single element and set "img" to the full array instead of a single element and it should work: img = document.getElementsByTagName('IMG');

Categories : Image

Change image depending on page title
Use document.title to get the window title, and set your image based on that. I used toUpperCase() to make sure you find the text you are looking for regardless of case. search() will return -1 if the text is not found. if(window.title.toUpperCase().search('APPLE') > 0) { //change image to apple } else if(document.title.toUpperCase().search('ORANGE') > 0) { //change image to orange } else { //use the default image }

Categories : Javascript

Change var value depending on which image is being swapped via jQuery
When adding or unadding add a class to the element. Then on your click check to see what class exists and then decide your action based off of that. <script> $(document).ready(function() { $('.thumb a').on('click', function(e) { e.preventDefault(); var $img = $(this).find('img'), $idshow = $(this).attr("id"), $action = 'add'; if($img.hasClass('thumbsUp')){ $action = "remove"; $img.removeClass('thumbsUp'); }else{ $img.addClass('thumbsUp'); } $img.attr('src', function(_,s) { return s.indexOf('thumbs_up_green') > -1 ? '../images/thumbs_up.png' : '../images/thumbs_up_green.png'}); $.get("thumb_up_tip.php?tip_id=" + $idshow + "&action=" + $action) }); }); </script>

Categories : Javascript

How to change the logo depending on page with javascript?
Because of you do not use jquery Try this in your case : To work in JS: if (window.innerWidth < 1024) {// code for small viewports //^^^^^^^^^^^ If you want to use jquery: function displaylogo() { if ($(window).width() < 1024) { $("#logo").attr("src","http://i.imgur.com/ozYV740.png"); // small logo } else { $("#logo").attr("src","http://i.imgur.com/RMV6Af0.png"); //big logo } } $(window).resize(function () { displaylogo(); }); $(document).ready(function () { displaylogo(); }); I suggest to use CSS instead: <span id="logo"></span> CSS: #logo { display: inline-block; width: 50px; height: 50px; background: url(http://i.imgur.com/ozYV740.png) no-repeat; /* small */ } @media screen and (min-width: 1024px

Categories : Javascript

Change the background image of a div depending on which link is selected in the navigation
It looks like you're using JS to add the class of selected to the menu. At the same time you're adding that, also add the the menu item name to the footer. something like: var menuName = $(this).attr('id'); $('.footer').addClass(menuName); Then in your css for the footer, add the class to the end of the element: .footer.menu-item-59 { // background goes here } based on your fiddle below, try: $(window).scroll(function(){ for(var i = 0; i < sections.length; i++) if($(window).scrollTop() +5 >= sections[i].top && $(window).scrollTop() <= sections[i].bottom){ sections[i].link.addClass('selected') .siblings().removeClass('selected'); var selection = 'selected' + i; // new stuff starts here $('footer #flag').removeAttr('class');

Categories : PHP

How to Change the
Try $(document).ready(function () { var $basic = $('.basic'), $maxi = $('.maxi'), $status = $('#status'); $basic.add($maxi).change(function(){ if($maxi.filter(':checked').length){ $status.text('Maxi') } else if($basic.filter(':checked').length){ $status.text('Baisc') } else { $status.text('') } }) }); Demo: Fiddle

Categories : Javascript

javascript change remaining dropdown values depending on first
Try $('select[name="category"]').change(function(){ var $this = $(this), $nextAll = $this.closest('tr').nextAll('tr').find('select[name="category"]'); $nextAll.val($this.val()) }); Demo: Fiddle

Categories : PHP

How to use the same [Storyboard] view for multiple tabs, and just change little things about it depending on the tab selected? (iOS)
You don't need a Storyboard for that. Sure you can drag a view in there and assign it to a specific class and program all stuff in that, but if you really need only one view in there the storyboard is useless. You should deal with subviews programmatically if you want to change something. This is very good and you have great features like animationWithDuration: For checking which Tab in your UITabBarController is selected you can use self.tabBarController.selectedIndex and compare it with the given Index of the Tab which is selected. EDIT: If we assume you have a green Button on Tab with index 0, and the same Button should slide a little bit above and a red Button should appear where green Button when Tab with index 1 is tapped. UIButton *greenButton = [[UIButton alloc] initWithFrame

Categories : IOS

Javascript - Seperating links depending of if link belongs to image
Sure, you are going to want something like this... I have not tried it, but its going to be close to this. var links = document.getElementsByTagName("a"); var textLinksArray = new Array(); for(var i = 0; i < links.length; i++) { if(links[i].innerHTML.match( /img/ )) { alert(links[i]); } else { textLinksArray.push(links[i]); } } //text links array only contains links without images. edited for keeping track of links sans img tags

Categories : Javascript

Python Pass multiple variables through command to change multiple lines in a text file with regex
I replaced the for loop with the following code and it worked: with open('test1.txt') as f: line1 = f.readline() line2 = f.readline() line3 = f.readline() build = re.sub ('build='r'.*','build='+buildpath,line1) apps = re.sub ('apps='r'.*','apps='+appspath,line2) logs = re.sub ('logs='r'.*','logs='+logspath,line3) tf.write(build + apps + logs)

Categories : Python

How change image of my battery widget depending on battery level?
I have achieved this in past projects by showing/hiding different views. Something like this in your updateView(): if (level > 90) { thisViews.setViewVisibility(widget_frame01, View.VISIBLE); thisViews.setViewVisibility(widget_frame02, View.GONE); thisViews.setViewVisibility(widget_frame03, View.GONE); } else if (level > 80) { thisViews.setViewVisibility(widget_frame01, View.GONE); thisViews.setViewVisibility(widget_frame02, View.VISIBLE); thisViews.setViewVisibility(widget_frame03, View.GONE); } else { thisViews.setViewVisibility(widget_frame01, View.GONE); thisViews.setViewVisibility(widget_frame02, View.GONE); thisViews.setViewVisibility(widget_frame03, View.VISIBLE); } Then, in your xml, set all of the imageviews to android:visibility="GONE"

Categories : Android

Set multiple variables to the same value in Javascript
Nothing stops you from doing moveUp = moveDown = moveLeft = moveRight = mouseDown = touchDown = false; Check this fiddle:

Categories : Javascript

Multiple Global Variables in Javascript
Typically libraries for client side Javascript each take at least one global because it would not be cool to require the user to use a module library. 0 global variables is a possibility in ES6 with first-class modules.

Categories : Javascript

JavaScript / PHP / Ajax set multiple session variables
You have to concatenate the parameters with an ampersand (&). Use this line xmlhttp.open("POST","session.php?function1Val=" + function1Val+"&function2Val=" + function2Val+"&jsStatus=" + jsStatus,true); BTW: I would really suggest to use jQuery or a similar library for AJAX requests. Furthermore I would use JSON for exchanging the data or a Javascript array where the key names are those of the variables.

Categories : PHP

Global variables in JavaScript with multiple files
You cannot access variables created from another page. You could use localStorage with cookies as fallback. function setSelectedSeat(seat){ if(localStorage) { localStorage['selectedSeat'] = JSON.stringify(seat); } else { //add code to store seat in cookie } } function getSelectedSeat(){ if(localStorage) { return JSON.parse(localStorage['selectedSeat']); } else { //add code to retrive seat in cookie } }

Categories : Javascript

Assigning multiple global variables in JavaScript with one function
function getBackList(urlName, globalVariableName) { $.ajax({ type: "GET", url: urlName, }).done(function (returned_data) { window[globalVariableName] = $.parseJSON(returned_data); }); } Pass in the global variable's name instead ^^^

Categories : Javascript

Concatenating multiple values returned by function with multiple variables without using temporary variables
What you ask is not generally possible. However, we can do some looping to abstract over the number of return values: my @strings = ("some text", "some other text"); my @ret = multi_return; $strings[$_] .= $ret[$_] for 0 .. $#strings; We can write a sub that in turn abstracts over that: sub append_all { my $suffixes = shift; $_ .= shift @$suffixes for @_; # uses aliasing behaviour to modify out-args } my $string1 = "some text"; my $string2 = "some other text"; append_all([multi_return()] => $string1, $string2);

Categories : Perl

Why do javascript variables in closure functions not reset to a default when called multiple times?
each time makeCounter is called through the "counter" variable That is wrong. You're only calling makeCounter() once – at var counter = makeCounter();. counter is a reference to the returned function, which closes over the i variable. Calling counter() will execute this returned function, just like any other function. The behavior you're expecting would happen if you write makeCounter()() multiple times.

Categories : Javascript

Change one image into the multiple images.
<form action="" method="GET"> <input type="url" name="image1"/> <input type="url" name="image2"/> <input type="url" name="image3" /> <input type="submit"/> </form> <?php echo '<img src="'.$_GET['image1'].'"/>'; echo '<img src="'.$_GET['image2'].'"/>'; echo '<img src="'.$_GET['image3'].'"/>'; ?>

Categories : PHP

Multiple image change on hover
I'm use sprite image to do this and change the position of another image to grey scale. I define 2 rows of images. Up for color and down for greyscale images. So when I hover the image, I change the another images position by changing y-position. But if you want to choose another method, You can use one pixel grey png box or css3 opacity and put it over the image to simulate greyscale.

Categories : Jquery

javascript of dynamically change image src
Easiest way to delegate event... In such way you don't need to add listeners per element Live Demo var parent = document.getElementById("rating1").parentNode; parent.addEventListener("mouseover", changeimg_color, false); parent.addEventListener("mouseout", changeimg_bw, false); function changeimg_bw(e) { if (e.target.nodeName.toLowerCase() === "img") { e.target.src='rating_bw.png'; } e.stopPropagation(); e.preventDefault(); } function changeimg_color(e) { if (e.target.nodeName.toLowerCase() === "img") { e.target.src='rating_color.png'; } e.stopPropagation(); e.preventDefault(); }

Categories : Javascript

cannot change the source of an image with javascript
var me = $('<div/>'); is basically (read: actually) creating a new node. You're adding content to that node, but you're never actually adding it to the DOM. You probably mean something like this: var newImage = ImageDisplay(images, currentImageIndex); imageDisplay.replaceWith(newImage) imageDisplay = newImage; That said, I have no idea if you've ever assigned imageDisplay a value inside of the DOM. If not, then you may need to initialize that value.

Categories : Javascript

Change Image transition with Javascript
Add this into your page <script type="text/javascript"> ustream={}; ustream.timing={}; ustream.timing.firstByte=(new Date()).getTime(); </script> EDIT After that $ is missing, it's probably jQuery. Import it than try <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> EDIT 2 You are missing this : <script src="http://static-cdn2.ustream.tv/packed/l10n/en_us/v6_home:13721527971.js" type="text/javascript"></script> EDIT 3 Import this : <script src="http://static-cdn2.ustream.tv/packed/l10n/en_us/v6_header_static_framework:13718193491.js" type="text/javascript"> You can use FireBug plugin in FF to see console errors

Categories : Javascript

javascript change Image by clicking thumbnail
Pass the image parameter to the function like, function changeImage(image) { document.getElementById("img").src=image; } <img src="img/thumbnail/test.jpg" alt="" id="img" onclick="changeImage('img/upload/test1.jpg')" />

Categories : Javascript

how to change image onclick javascript function?
What you've got should work. Here's a shorter version: function changeImage() { this.src = this.src == "imgs/left.gif" ? "imgs/right.gif" : "imgs/left.gif"; }

Categories : Jquery

Change image after number of clicks using javascript
This would be a nice way of doing it. It's easy to read, and hopefully makes sense. var count = 100; var image = document.getElementById('myimage'); var images = ['default.jpg', 'crack1.jpg', 'crack2.jpg']; image.src = images[0]; image.onclick = function(e) { if(count > 50) image.src = images[0]; else if (count > 25) image.src = images[1]; else if (count > 0) image.src = images[2]; else { //do something here to indicate the end } count--; };

Categories : Javascript

Javascript doesn't change background image
Try this instead (no jQuery needed): <select onchange="bg(this[this.selectedIndex].value)"> <option value="1.png">Skin 1</option> <option value="2.png">Skin 2</option> </select> function bg(num) { document.body.style.backgroundImage = "url(http://mk7vrlist.altervista.org/backgrounds/" + num + ")"; } jsFiddle example (note the second option doesn't change anything as you don't seem to have an image for that URL.)

Categories : Javascript

Can't change Image during onclick event in javascript
getElementsByClassName returns a collection, not a single element. You may do this : var imgs = document.getElementsByClassName('imgclass'); for (var i=0; i<imgs.length; i++) imgs[i].src = "Images/square.jpeg"; But it would be probably cleaner to give an id to your image and use getElementById. Note also that you seem to hesitate on the spelling of botón/boton/buton and that will make it hard for the code to work. You should see errors in the console.

Categories : Javascript

How to structure the code to process multiple variables from mulitple form elements in JavaScript and remember the choices?
Maybe use jquery.form.js? http://malsup.com/jquery/form/ It's a great plugin, just structure the form like it was a normal redirection form, add array in name of checkboxes <input type="checkbox" name="types[]" value="21" />Beachfront Add target URL to the form, and then... When u want to submit the form just do $('searchform').ajaxSubmit({ success: function() { // callback } ) Trigger this on checkboxes change, dropdown change etc. To make the code clean, use one selector $('#country, #s, #color input').on('change', sendAjaxForm);

Categories : Javascript

Changing values of variables depending on a factor
If you want T to be a sequence starting at 0.1 and increasing by 0.1 for each group defined by column A, you can use the following code: DF$A <- sample(LETTERS[1:3],20,T) # fake data #> DF$A # [1] "B" "C" "C" "C" "B" "B" "A" "C" "A" "C" "B" "C" "B" "B" "A" "C" "C" "A" "A" "C" DF$T <- ave(as.integer(DF$A), DF$A, FUN=function(x)seq(from=0.1,by=0.1,length.out=length(x))) Result: > DF[order(DF$A),] A T 1 A 0.1 2 A 0.2 3 A 0.3 4 A 0.4 5 A 0.5 6 B 0.1 7 B 0.2 8 B 0.3 9 B 0.4 10 B 0.5 11 B 0.6 12 C 0.1 13 C 0.2 14 C 0.3 15 C 0.4 16 C 0.5 17 C 0.6 18 C 0.7 19 C 0.8 20 C 0.9

Categories : R

Fade and replace image with other image depending on hash
You need to use onload plus hashchange window.onload = checkHash; window.onhashchange = checkHash; function checkHash() { // check stuff } Working Fiddle :: careful hash does change :-) http://jsfiddle.net/R9cNW/9/

Categories : Javascript

How do I change the background image position on a website using javascript?
What you want is: function size() { document.body.style.backgroundPosition = "0px 30px"; } Explanation: Access the body using document.body body.style.backgroundPosition: "0px 30px"; should be body.style.backgroundPosition = "0px 30px";

Categories : Javascript

How to passing Repeater Row ID to javascript/jquery and change image
After trying out my previous proposed solutions, I've decided to rewrite the answer from the scratch. I created a new project here on VS and tested the code below. It's a simplified version of what you have, but it will work just as expected: 1) Note that you won't no longer need the OnClientClick event attached. 2) Just define the CssClass to your LinkButton and attach a handler to the click event. <head runat="server"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { $(".linkButton").on("click", function (e) { // As I don't have any code running on the code behind, // it would replace the ima

Categories : C#

Use javascript replace to change image url on page load
My guess is you've got a series of images that you want changed and its only changing one for you. A general innerHTML replace probably isn't the best way to go about changing image sources. Try something like this: function replaceScript() { var images = document.querySelectorAll('img'); for(var i = 0, l = images.length; i < l; i++){ images[i].src = images[i].src.replace("-1.jpg", "-2.jpg"); } }

Categories : Javascript

Javascript clock to change hour, minute, second with image
Ordinarily I'd approach this with a sprite sheet in mind as you have 135 unique images and traditionally that would mean 135 requests to a web server which would result in poor performance. Technically your images are simple enough that the effect could be generated using CSS or SVG quite easily too... However because that feels like cheating the question and because you haven't specified a particular size for your clock; I've stuck with a solution using individual images - though I have taken measures to optimise your images for this example which I will explain first. The images in your zip file are 400x298 pixels totalling 4MB (this is arguably not web-friendly) and if you can't resize them (IE. you actually want a big clock) then you should consider compressing the images. For th

Categories : Javascript

JavaScript How to make an image to change color onmouseover?
You can change image SRC on mouse over, you can load two images and use fade effects to "change" them. But better, you can use image as DIV background, make sprite and just move BG on mouse over. Loading of two different images bring you to disappearing when hover and second image loading. Better do not use JS at all. Make sprite from two images, put it as BG of DIV and write two CSS for DIV, normal and when hover.

Categories : Javascript

BundleTransformer.Less inject variables depending on context/request
Michael! You use the Microsoft ASP.NET Web Optimization Framework and the Bundle Transformer in multi-tenant environment, so you need to replace some components of the System.Web.Optimization and create own versions of the debugging HTTP-handlers (see «Problem: LESS file imports are added to BundleResponse.Files collection» discussion). As far as I know, Murat Cakir solve all these problems in the SmartStore.NET project. In the Bundle Transformer there are 2 ways to inject of LESS-variables: Look a properties GlobalVariables and ModifyVariables of LESS-translator: using System.Collections.Generic; using System.Web.Optimization; using BundleTransformer.Core.Builders; using BundleTransformer.Core.Orderers; using BundleTransformer.Core.Transformers; using BundleTransformer.Core.Transl

Categories : C#

Enable function depending on template class variables
You can just use && and == in the argument to enable_if. Also, you forgot the ::type, which is the member that only exists when the condition is true (and so does the enabling). This also requires adding a typename. Here is the code that works: #include <type_traits> template <int m, int n> class matrix { public: typename std::enable_if<m == 4 && n == 4, void>::type translate(float x, float y, float z) { // Do stuff } private: float mat[m * n]; }; int main() { // Compile fine matrix<4, 4> mat4; mat4.translate(1.0f, 1.0f, 1.0f); // Compile error matrix<4, 3> mat3; mat3.translate(1.0f, 1.0f, 1.0f); return 0; }

Categories : C++

How to change an image tag url in multiple html files using batch script?
@ECHO OFF SETLOCAL enabledelayedexpansion for /r U: %%i in (*.html) do ( echo found %%i SET outfile="%%~dpni.lmth" ( SETLOCAL disabledelayedexpansion FOR /F "usebackq delims=" %%L IN ("%%i") DO ( SET "line=%%L" SETLOCAL ENABLEDELAYEDEXPANSION SET "line=!line:/live/=/test/! echo !line! ENDLOCAL ) ENDLOCAL )>!outfile! ) pause GOTO :EOF How about this development? Notes: I've modified your FOR/R to ECHO the HTML file being processed and use %%i rather than switching to %%f. U: is my RAMDRIVE; you'd need to modify that to suit. outfile is set to generate a filename which matches the HTML filename, but with a .lmth extension (can't update in-place) - it gets that from the ~dpn prefixing the i, which means the drive, path and name of the file %%i. It's

Categories : Batch File

PHP / DOM method to change image-paths that are not within
 or  tags, without JavaScript
This is a quick work, so it may not look nice, but hopefully you get the idea. Online demo function walkDOM($node) { if($node->nodeName=="pre" || $node->nodeName=="code") { return; } elseif($node->nodeName=="img") { $node->attributes->getNamedItem("src")->nodeValue=str_replace('desktop-img','mobile-img',$node->attributes->getNamedItem("src")->nodeValue); } elseif($node->hasChildNodes()) { foreach($node->childNodes as $child) { walkDOM($child); } } } function changeImagePath($html) { $dom=new DOMDocument; $dom->preserveWhiteSpace=true; $dom->loadHTML($html); $root=$dom->documentElement; walkDOM($root); $dom->formatOutput=false; re

Categories : PHP



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