I know this is sorta reposting but I want to simplify the issue a bit. Take the following script:
function replacemain(s){
var x = document.images['MainImage'];
var y = document.images[s];
var pictemp = x.src;
x.src = y.src;
y.src = pictemp;
}
All I want to do is replace the image specified as "s" with the MainImage. Actually swap them so that each execution of the function will swapp and reswap the images without loosing anything. This generally works, however, on a couple IE6 browsers it causes blank images to swap in....
I've got a JavaScript / CSS question if anyone has a spare minute and the interest? I've got a page with a background image set by CSS. I want to use a Javascript function to change that image with a link click. Here's a snippet from my HTML:
HTML Code: <body> <script type="text/javascript" src="changeBGimage.js"></script> <style type="text/css"> body {background: url('red.jpg') no-repeat} </style>
[Code]...
Would you be able to tell me how I would structure that function?
I need to create a page containing five image tags, two buttons, a <select> and a <textarea>. The images tags will each contain a picture of one of six possible outcomes for the dice portraying the numbers one through six..
The first button: When the user clicks on the button, all dice are rolled once. For each die when rolled, the src of its image tag is replaced with a random one of six possible pictures -- each picture being chosen with equal probability (1/6).... I HAVE THIS DONE
The select: The user may select any of the numbers one through six. Whenever a picture is clicked upon, then that die takes on the value shown inside the <select> THIS IS WHAT I NEED HELP WITH
The textarea: Results of the dice rolls should be kept as a running log (a cumulative history) in a textarea at the bottom of the page. With each roll (initiated by the click of the button), we should be able to see the complete history of all current and previous dice rolls. You need not consider changes brought about clicks on individual dice in conjunction with the <select>....I HAVE THIS DONE
The second button: A button below the textarea, should allow the user to obtain a report (overwriting the current contents of the log in the textarea) which tabulates the frequency of each of the six outcomes plotted separately for each of the dice. The frequency tabulation should show how often each die was rolled, as consistent with the data stored in the log..
I have an image inside of a div that I'd like to swap every time the function is triggered. I was able to attach first image through this: Code JavaScript: this.titlecontainer.appendChild(document.createElement('img')).src = 'images/picture' + padded_index + '-t.png';
This indeed does add another image on each function iteration but as the code suggests, it actually APPENDS additional images. Instead, I'd like to SWAP the existing image for a new one. My guess is to remove what's currently loaded inside the div prior to appending another one. What would the line preceding the above have to look like to accomplish removing of the content?
What I would like to do is enable swapping between the black images? I would like to drag and drop to another image and that image will fill up the dragged earlier image position?
I've run into a problem with swapping images for site navigation.The "hover" part works just fine, but the problem lies within the click part. When the user clicks the first thing that happens is to reset all of the images for all of the links, and then set the hover image for the link that was clicked. However it seems that after resetting all of the images 'src' attributes, the code for setting the link that was clicked either doesn't execute, or executes before the reset.
working on a feature that displays 3 news stories. The stories are accessed by 3 buttons on the top, sort of like a tab-style navigation. The catch is that all 3 stories are on the same html page, the "navigation" is just showing/hiding content based on Java, CSS & div's. Where I'm stuck is creating On/Off state for the tab buttons. What I'd like to do is:
Naturally I have separate version of each button for the on/off state, I'm just not sure how to initiate the swap...Do I set a JS variable on the onclick? Or is it just a function?
Newbie here. I am seeking to swap out three images when rolling over one. Cursor hovers over one image - three new images, in different locations, are seen on screen. When cursor moves away - the images revert to "normal" state.
Image 1 - thumbnail - bottom right of screen When rolling over Image 1, three images change: Image 1 - to shaded version of the thumbnail Image 2 - main image center of screen Image 3 - text box image top right of screen
What I would like to do is enable swapping between the black images? I would like to drag and drop to another image and that image will fill up the dragged earlier image position?
I am trying to create a menu that would look and act like this image illustrates: [URL] Essentially the three boxes slide down when rolled over and menu items appear in the portion that has slid down.So far, I have figured out how to make an image slide using jQuery: [URL]
When selecting male or female auto fill in the appropriate blanks. The idea is I'm trying to write a Kids book that lets them make there own adventure. So what would happen is as an example they could select "I'm A boy/girl"
And in the story two different possibilities would come up that being: A: (Boy option selected) He grabs his Sword and prepares himself for battle B: (Girl Option Selected) She Grabs Her Sword and Prepares herself for battle The only way I can figure out how to do it so far is by making them select "S/he, His/Her, Herself/Himself" ext. But I wanna make it one simple button...
I have been using the jquery autocomplete plug-in for some time now and find it very useful. Lately I have come across the following problem in one of my JSP pages. The autocomplete suggestions are displayed and formatted properly. But when I select the one that I want, the result briefly appears in the input field and disappears. Simultaneously, the entered result automatically triggers another jquery search. The contents of my JSP page is given below. The same jquery code works perfectly well with other JSPs.
Code: <%@ include file="../common/include.jsp" %> <script> var cols = []; // column mappings : 0=Last name, 1=First Name, 2=Title, 3 = Employee ID $ .ready function { .....
I am looking for JS script to replace find all the href values on a page and replace those href values matching them with an array of values.my array, lets say is a = {'some.ex.com', 'abc.ex.com/tv', 'some. name. ex.com', 'bcd.ex.com/dir1/dir2/some.jsp' }; etc.i want to find all the URLs on a given page, check if each found url matches with any of the values in the array, if match found, just replace only "ex.com" with "example.com" for every match.
I'm hoping that there is a simple script that can rotate images and text links on a page, always showing perhaps 5 or 10 images although in a different order every time. This would be used to equalize ads on a few of my sites, an example can be seen here Code:
okay, now i know this is probably really easy, but i have about a 2% knowledge of javascript (i know i should learn it)
anyway what im after is something that will do the following
i have 1 image that is 160x106 pixels, on the other side of the page i have 5 thumbnails (16x10pixels) now when somebody clicks on one of the 5 thumbnails i want the full size version of that picture to apear where the 160x106 picture is...
How in javascript can I swap the cells in a table? I know I can copy the innerHTML and style and other bits manually but can I just swap 2 cells in different rows?
I was wondering if there is a method to swap the contents of a div with jquery? The event is triggered when internal elements are clicked. Say and image and a link within the div, and also to be able to jump back to the same div with the same events.
I'm trying to create a jquery nav that will show up in place of the existing paragraph or div with a ul, then on the mouse out replace the existing paragraph. I'm not not too experienced with javascript, so I'm hoping it's just a simple and easy fix.This is what I have so far. I managed to get it to work, somewhat, but the paragraph shows up if you mouse off the main button over the ul. And for some reason it doesn't always show the menu on the mouse over, is picky about which ones it does.
I'm trying to set up a series of questions, which would look basically like an unordered list. Then, upon clicking a box next to any of the questions, the answer would appear underneath the question. Clicking that same box a second time would cause the answer to disappear. It seems very simple, and I've tried using a couple of different text swapping functions, but for some reason I can't get the answer text to appear in the right places. The script seems to have a hard time keeping track of where things are supposed to go, and it's really irritating me. I need to find a solution ASAP.
I´m completely new at javascript, and I got a little issue. I want to be able to have some text in my index-page and 2 buttons to change this text back and forth with diffrent text. Say i have one headline like this
<div id="first"> <h1>Hello world</h1> <p>Lorem ipsum etc............</p> </div>
and i want 2 buttons under this text beeing able to swap all this code for say this:
<div id="second"> <h1>Hello president</h1> <p>Lorem ipsum etc............</p> </div>
and most likely sevral more swaps, so the buttons would work like a library function.
Can anyone point me to an image rollover script that uses id and not name in the img tag?
I'm trying to validate a page (using validator.w3.org) that uses the name attribute in support of some javascript image rollover script, but this is causing the validator to error.
I need to build a page that allows users to ordinally rank elements (first, second, third etc.) and then add a numeric value to indicate the difference between each rank (3.2 or 27.8, whatever). I have a base ordinal ranking that I would like them to start from but I need the user to be able to move individual elements up or down to indicate the ordinal ranking.
Does anybody have a working example of something like this that I can look at? I can do the coding, but I am more interested in looking at the interface to get some ideas on a 'clean' way to go about it.
i have looked around all over the place for some code that will do this, but everything seems to fall short. i'm relatively new to js, but this seems like it would be one of the more simple things to do.
basically, i'm after an effect similiar to the "sign in" box at the top of twitter's pages - not the pop-up form, just the swapping images and background colors, etc. i have a couple of simple scripts that work, but only with simple text and not blocks of code - i.e. a div with a class containing some text and a small image.
all of the examples i have found involve swapping the div from a source somewhere else on the page, such as a menu or something similar, which is obviously not the same thing.
I have a simple navigation bar using an ul with images.
I have the following script that swaps out the images on mouseover and mouseout to create "hover" effect.
The issue is when I try to set the src attribute of the image that has been clicked the image does not change. The first part of the click event is working and resets the src of all the images as expected, but the second part that sets the src for the image clicked does not either run or runs before the reset.