Switch Image By Variable?

Apr 12, 2011

I'm writing an image gallery script in which the thumbnail for the currently-viewed image is indicated with a smaller image below the thumbnail. My placeholder is as follows:

<img name="indicator0" alt="indicator>

with indicator1, indicator2, etc. following, one below each thumbnail. In my script, which placeholder has the indicator is called by the variable thumbIndicator. I'd like to be able to do that like this:

document.(thumbIndicator).src = "indicator_image.jpg";

but this has not worked. I've also changed my image placeholder to this:

<img id="indicator0" alt="indicator">

and the script to this:

document.getElementByID(thumbIndicator).src = "indicator_image.jpg";

View 6 Replies


ADVERTISEMENT

Using The Switch Statement And Variable Scope?

Jun 14, 2010

I've created a jQuery script that uses a switch statement. However, my experience with it, relative to variable scope, doesn't seem to follow the logic.According to the JavaScript/jQuery theory, a global variable was accessible (meaning read & write) throughtout any function within any script (one that page).However, apparently that theory wasn't completely true as it pertained to switch statements that contained variables. To illustrate my case in point, I've included a simplistic version of my code:

$("#selector").delegate("div", "click", function(event) {
var testVar = 4;
switch (this.id) {

[code]...

As shown, the variable "testVar" is not accessible from one case to the next case .Furthermore, to add insult to injury, I am seeing the same behavior within the conditional if else statement counterpart to the switch statement.

View 1 Replies View Related

Getting Switch Image To Be A Link As Well?

Apr 13, 2011

I'm trying to create a switch image code that will allow the new image to be a link as well. In the list item where you'll see ('blue.jpg') if I try to make this an anchor tag - it breaks the code.

<head>
<script>
function switch1(div) {
if (document.getElementById('blue')) {

[code].....

View 6 Replies View Related

Image Switch Function Using Array?

Oct 9, 2011

I have the following as a code for an image rotation on each click (with three images)... when I load the page the first image loads fine and I click on it twice and the other two images switch smoothly, but then click a third time to go back to the first image and it doesn't go back to the first image. here's the javascript:

Code:

imgs=Array("pics/adv/chrebMs1.jpg","pics/adv/chrebMs2.jpg","pics/adv/chrebM.jpg");
var x=0;
function change() {

[code].....

and heres the html:

Code:

<img src="pics/adv/chrebMs1.jpg" id="chrsc" alt="" onclick="javascript:change();"/>

View 2 Replies View Related

Switch Image On Expanded Content?

Mar 12, 2011

Im creating a javascript content expander and would like to know how to create it so it changed the image from an down arrows to open the box, and a down arrow to close the box.Here is my current code.

Code:

<script type="text/javascript">
//var persistmenu="yes"
var persisttype="sitewide"

[code].....

I want the <div class="rightnews"> thing to change from an up arrow to a down arrow.Here are the icons im using.for the box to contract:

for the box to expand.

View 1 Replies View Related

JQuery :: Switch Image Source During Toggle?

Oct 2, 2009

I have some divs I am toggling and there is a little + sign image I want to change to a - sign image when the toggle event occurs, but can't quite figure it out. Here is the toggle code I have (taken from

[Code]...

View 5 Replies View Related

Switch Between Two Images - Session Image Switching

Sep 27, 2011

I have a site where i switch between two images using some JavaScript. What I need is to be able to set a session variable or something so that if someone selects shading on or off it sticks to that for the rest of the session.

Any idea or even a point in the right direction. Do i need cookies or is there a simple way to do this

[url]

View 13 Replies View Related

OnLoad Image Event Style Switch

Aug 18, 2009

Been trying to get a short script I wrote to work 100%. Basically it checks to see if the main page image is =>375px and if it is shunts the text down below it. Its not a live site yet and due to it being so short I thought I would just copy and paste it here:

function checkImage(imageId) {
if(document.getElementById) {
var id = document.getElementById(imageId);

[code]....

The problem is with IE6, it randomly decides not to work without any sign from the debugger that anything is wrong. This is my first time using onLoad with an image, is there any quirks with it such as page load order (e.g. if the image finishes loading before the text loads this wouldn't appear to run?).

View 1 Replies View Related

JQuery :: Image Switch : Custom 'hover' Event Fails / Resolve This?

May 25, 2010

It's kind of hard to start explaining what i did or maybe even harder why i did it that way. But ok i neededtext replacement for custom fonts. Cufon couldn't be used because of the large amount of text and javascript in general on the site. It should play nice on IE6 that's why i chose to use facelift(server side text to image replacement). The problem arose when i needed to show a different font on hover state. I created two elements with the same position and now i want to switch them on hover state! It's actually working but when hovering fast over the different elements the hover state's mixes up ending ugly and wrong...

View 1 Replies View Related

Show An Image Only If Theres Something In The Variable

Mar 3, 2011

I'm trying to figure out how to show an image in a div in a certain order (but only show if the variable that corresponds for that image has something in it).

I basically need something like the following...

But that code doesn't work.

View 1 Replies View Related

CSS Background Image Using A Variable?

Jul 8, 2010

I am attempting to put a simple slideshow of pictures on our company's website as the background of a div. The code I have works fine for a single picture:

obj.style.backgroundImage = 'url("photo.jpg")';

but does not work when I try to use a variable for the file name instead of the file name itself, ie:

obj.style.backgroundImage = 'url("processed[i].src")';

Is there anyway to set the background image using variable names? I really don't want to have to use a switch statement with each case being a different picture.

View 5 Replies View Related

Image Moving Code Variable ?

May 13, 2010

I have been trying to write a java scrip that will move an image (image1) to the pixel location that the user inputs into a text box.

Here is what i have so far:

HTML Code:

I am not sure if the problem is in the variables or setting the variables based on the numbers in the text box.

View 1 Replies View Related

Slideshow With Text Descriptor - Variable Image Size ?

Feb 17, 2009

I am trying to create a slideshow. My requirements are as follows:

-variable image size
-descriptor text for each image
-previous and next image function (I have used an image in my code by have decided that I would now prefer a text link)

Here is the code I have so far, currently the image and text is not changing!

Code:

View 8 Replies View Related

Call Variable Content Via Image Maps And OnMouseOver?

Jun 14, 2010

I'm developing a multi-layered diagram as a web-page. The layers show versions of a network as it grows, with various components. I have created an image map on each layer. At the side, there is a panel where I want to display info about each component as I mouse over each element.

As a test, I used getElementbyID and inner.Html with a Javascript called writeText to display text in the side panel. However, as there are 6 layers and 20 - 30 images on each layer, I don't want to embed the text in each image map as it will make updating content a hassle and long home page.My idea is to use the ID of each image map as a variable and call the associated content from a separate page (XML maybe?) by naming the content section the same as the ID of the image map. I need to write some script that would work something like:

onMouseOver="writeText(call content with name="imagemapID")

View 3 Replies View Related

Substitute The Image Variable Into The Html Instead Of A Hardcoded String?

Jul 16, 2009

I know I must be missing something stupid, but can someone explain to me why:

PHP Code:
<html>
<body>

[code].....

View 5 Replies View Related

Continuous Horizontal Variable Width Image Files Ticker?

Mar 10, 2009

My client wants a ticker, only with client logos. I've found several scripts which are cool, though no one is precisely what I'm after. Company logos vary in their proportions. I'd like ideally a script able to continuously horizontally animate images of the same height, but with variable widths. Found plenty of scripts moving same width images left/right, or using a carrier (table/div/layer) to contain a set of variable width images - the latter leads to blank moments my client doesn't like while the carrier is repositioned.

I'm very intrigued as to why this doesn't seem to have been done and wonder if there's a reason. Is the computation needed in passing widths in a variable to a move function too much for the client-side? I don't want to waste my time wading into repurposing a script for this if it's not viable as I can't pass that cost on to the client, you see. I'd rather bail and do it using Flash.

View 9 Replies View Related

Switch Problem

Jul 23, 2005

I have some function to Preload images and make MouseOver etc..

But when a put a Switch statement in one of my function (MouseOver), a
receive an error on body load in my preload function.. did someone have any
idea why ?

Here's my switch code :

function setOver(num)
{
var txt;
obj = eval('document.getElementById("image' + num + '")');
obj.src = imagesHover[num-1];

txt = '<img src="' + imagesInfo[num-1] + '">'
document.all("infoDiv").innerHTML=txt;
document.all["infoDiv"].style.display='block'

Switch (num)
{
Case 1: alert(num);Break;
Default: alert("hello");Break;
}
}

View 2 Replies View Related

Make An 'on' 'off' Switch

Mar 23, 2009

I'm trying to make an 'on' 'off' switch

the idea is for imgA to 'toggle' with imgB onMouseDown (onclick is used to call a function)

I can get the image to swap once but not back again. I have no idea if the way i'm attempting it is even close.

<script type="text/javascript">
function imgswap(){
if ( )
{

[Code]....

View 8 Replies View Related

Switch Menu

May 14, 2007

I'm trying to install a menu for my website. I am using a script I found here: http://www.dynamicdrive.com/dynamicindex1/switchmenu.htm.

The code works great, but I would like to customize it slightly. Instead of being a vertical menu, I would like it to be a horizontal one, with all the main links at the top of the page, and with each link opening a horizontal sub menu beneath it.

I managed to create a horizontal list by changing the 'div' to 'span' and altering the HTML and CSS slightly. Now I have a horizontal menu that opens submenus when I click!

My only problem now is that instead of opening each submenu below all the links, it opens it below the link in question. So, for instance, let's say I have three links: Info, About, and Contact. If I click on 'About', it opens up a submenu under Info and About, and pushes Contact down to a new line below the submenu. If I then click on 'Info', it closes the previous submenu and opens a new one below Info, with About and Contact in a new line.

My JavaScript skills are pretty poor, so I was wondering if someone could help me identify where in the JavaScript I need to make changes so that the the submenus open below ALL the menu elements. Code:

View 2 Replies View Related

Switch Statement

Nov 1, 2005

This is my first time using the switch statement. I would appreciate your suggestion on how to do this properly. I am trying to get customer age which is (age) and compare it with the monthly rate then the text msg will display in the textarea. Also, I am having trouble figuring out how I can defined my monthlyRate in the switch or do I need to this outside of the switch? Code:
}

View 10 Replies View Related

Switch Ie/firefox Css

Feb 2, 2005

im looking for a nice javascript cde which switch css link href when browser is detected.

View 9 Replies View Related

Switch Function

May 31, 2007

I am using a switch function to toggle those links for display and unlink image will be hidden. But I have just duplicated the first block of javascript for the second tab, it didn't work. This is the first block of switch function, it works for first tab: Code:

View 4 Replies View Related

Switch Off A Js When Printing?

May 6, 2010

I'm trying to make a printable version of a webpage using the css @media tag. On the page is a javascript which works great for the on-screen version but I need to find a way to switch it off when printing as it hides content.

Beyond building a separate page I can't think of anything obvious!

View 1 Replies View Related

Multiple Arguments In Switch?

Jul 23, 2005

As I can remember this is not allowed in Java:

int x, y, z;
switch(x,y,z){
case 1,2,3:
System.out.println("Hep");
break;
}

But what about in JavaScript, or are there some other kind og syntax for switch?

View 2 Replies View Related

Switch Content If Low Bandwidth

Sep 24, 2007

Is there a way where I can "guess" what relative speed the user's
connection is?

Currently, the client is wanting some graphical intensive content and
I'd like to be able to warn users on dial-up to allow them to go to a
"gracefully degraded" version.

I thought of simply putting up a question for users to answer but the
client would rather it happen, more or less, automatically.

View 7 Replies View Related

JQuery :: Switch Position With Other Div?

Jun 25, 2011

If I have this code:

<div id="test" bla="1
">Hey</div>
<div id="test" bla="2

[code]....

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved