Switching Image Back And Forth Using OnClick?
Mar 27, 2011
I want to create the form button similar to this: [url]
I use an OnClick to switch the image but the if else statement just doent let me switch back to the original image, i not sure where i have gone wrong...
Below are the html and js thumnails:
[url]
[url]
View 1 Replies
ADVERTISEMENT
Aug 26, 2005
I don't have much experience with JavaScript, but this is so simple I can't understand why it doesn't work. Basically, when the user clicks the image of a gray arrow it switched to a green arrow and vice verca.
<SCRIPT TYPE="text/javascript">
function swaparrows() {
var x=document.images
x[0].src="../images/green-arrow.jpg";
}
</SCRIPT>
<img src="../images/gray-arrow.jpg"
But that only works once of course, I want users to be able to switch back as well, so I changed the function to what I thought would work:
function swaparrows() {
var x=document.images
if (x[0].src=="../images/gray-arrow.jpg") {
x[0].src="../images/green-arrow.jpg";
}
if (x[0].src=="../images/green-arrow.jpg") {
x[0].src="../images/gray-arrow.jpg";
} }
but it doesn't. I am used to PHP, but as far as I know IF statement works the same way.
View 4 Replies
View Related
May 1, 2009
Let's say I have three images - one large image and two small thumbnails like so.
<p>
<img src="1_large.jpg" width="200" height="200" />
</p>
<p>
<img src="1_small.jpg" width="100" height="100" style="padding:0 5px;" />
<img src="2_small.jpg" width="100" height="100" />
</p>
Now, what I'm trying to achieve is: When you hover over the 2_small.jpg the 1_large.jpg temporarily changes to '2_large.jpg' until you mouseout then the image reverts back to '1_large.jpg'. If you click on the '2_small.jpg' thumbnail the '1_large.jpg' permanently changes to the '2_large.jpg' until you either hover/click on the '1_small.jpg' thumbnail.
View 2 Replies
View Related
May 12, 2009
I have a script that has several links and when you rollover the link it changes a main picture to be view as an image. But, when you no longer mouse over the link, it switches back to the default image.
I'd like for the last link that was rolled over to stay enlarged as the main pic until you roll over a different link.
Here's the current script...
In the head:
View 1 Replies
View Related
Dec 11, 2009
I have a navigation pane with 4 links. Two of these links show collapsable submenus. When one clicks a link, I want the CSS class of that link to change. For the two "real" links, I've just changed the class on the page itself. For the two collapsible menus, I'm trying to employ javascript.Ultimately for these two links, I want the class to change when clicked, and change back when clicked again.Here's the code for the page:
<div id="navigation">
<ul>
<li><h3><a href="javascript:;" onclick="changeclass(this);" onmousedown="toggleSlide('slidemenu');" class="colmain">COLLAPSIBLE MENU[code]....
1. Seeing as I've been working with javascript for a grand total of six days so far, could you explain the best way to make my code work? What's the significance of colstatus=obj?
2. The javascript works if I leave out the else statement. It will change the class after being clicked, but, of course, doesn't change it back. However, if I click the other collapsible menu, it will change as expected, but the first will revert back to the original class. Why is this happening?
3. Seeing as the code is adopted, I have no idea what /*<![CDATA[*/ and /*]]>*/ mean. Would you explain?
View 2 Replies
View Related
Apr 8, 2009
I have created a long list of items. For each item, there is 1 image. In my case, I use the same image each time.
I would like to use JS to allow users to check an item by clicking on it. Please note, I am not using radio buttons or any other forms.
This is my JS function:
It is triggered using this:
It works for each image. It switches to 2.png when a user clicks on each instance of that image. But how do you make sure it switches back to 1.png on the next click, and so on, effectively creating a switch for multiple instances of the same image?
View 2 Replies
View Related
Jul 1, 2011
I looked around to see javascript codes on websites but had no luck in finding what I wanted... or I just don't know how to work with it.
I want to switch/replace image with other images by clicking on radio buttons. i have the html, but how can I make this work?
<body>
View 8 Replies
View Related
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
Jun 11, 2009
I have a banner that has image navigation on the lower right. The navigation links are images which, when clicked, change the banner without reloading the page. The actual switching of the banner is working when each image is clicked.
However, my problem is this:
The page itself is long and must be vertically-scrolled to see the entire content. Because of the scrolling, the banner could appear anywhere vertically on the page. And whenever I click the banner navigation hrefs, the page "jumps" so that the banner is at the top. The page should really stay in the fixed position.
I'm not sure how to set it up so that no matter where the banner section is on the scrolled page, that the page stays in the same position when the navigation is clicked.
My href's in that navigation are set up as :
Do I need something in my script so that the page won't jump? Or am I missing something in the HTML?
View 3 Replies
View Related
Sep 22, 2005
Have a slideshow navigation and want to put a DOM onubtrusive JS that finds the <a> in <li id="nav-back">and executes history.back() with a onclick handler. No worry about JS disabled because then I use a other link that is hidden when JS is enabled ...
Some questions-ideas
What do i need to put in the <a href="??"> of <li id="nav-back"> ?
And the script I started see below, should it be written like that ??
History.back() works perfectly cross-browser in DOM capable browsers ??
This is the HTML
<div id="navwrap">
<ul id="nav">
<li id="nav-prev"><a href="#" title="go to previous image">previous</a></li>
<li id="nav-back"><a href="#" title="go to overview of images">back to overview</a></li>
<li id="nav-forward"><a href="#" title="go to next image">next</a></li>
</ul>
</div>
Is this how to do go about it
if (!document.getElementbyId) {return;}
var backButton = document.getElementbyId('nav-back').document.getElementBytagname('a')
backButton.onclick = history.back();
}
Is it possible to show in the title tag that last history entry ?
View 2 Replies
View Related
Jul 27, 2011
I am trying to recreate this functionality on my website where you can drag a background image around and when you get ot the edges of the image it bounces back to the edge of that corrosponding side. have a look at the site in question - [url]
So far i have recreated the top left and right edges using
Code:
Here is how i thought the bottom would work
Code:
View 9 Replies
View Related
Jun 2, 2011
My problem is similar to an earlier issue here but I have a script directing the HTML form. I want to change the "button" to an image in my cpanel and have tried an earlier answer with no luck.
I did manage to get the button replaced with my image but the javascript does not work and allows a signup to bypass filling out the form and go to the destination page.
The script works perfectly with the "button" but I really would like to have my image I made.
Here is what I have with the "button" :
View 12 Replies
View Related
Feb 15, 2012
I have an ajax call that sends some data to process.php and return back the image name. In process.php I returned the name as follows:
echo "image.png";
The ajax call is:
var $chart = $( '#chart' );
var $test = $( '#test' );
[Code]....
so from test div i get the path printed right: (./images/image.png), but I don't get the image to be desplayed
View 2 Replies
View Related
Apr 16, 2009
I try to find working example, but no luck.I need this very simply javascript to onClick change value and second click change value back and third click change value again back and so on..
View 7 Replies
View Related
Jul 20, 2010
I am using ContentFlow from [URL] It is very well documented on their website. I got the whole thing working great on my site. What I don't know is how to change the ActiveItem onclick to just bump it over to the next image as if the next image had been clicked. As of right now it opens the image source in a self window. I don't want that. Can anyone give me a clue or maybe the whole answer on how to get it to click over to the next image? I believe the answer lies in the contentflow_src.js file.
View 6 Replies
View Related
Jul 24, 2009
I am trying to make a point and click javascript game. Basically what I want is to have one image displayed on screen at the start (room1.jpg). When you click on a door on that image, I have an onclick event to change the image to a new one that shows the door open (room1_a.jpg). What I want is that when you click the now open door, to display the next room in the game. The only solution I can think of is some sort of nested onclick event using several image maps, but I am fairly new to Javascript and I am not sure if that is possible. What it all comes down to is I want to display each incarnation of each room in the game in the same window without having to reload a new window for each room. I hope that makes sense, if not I can try and clarify. Below is the code I have so far. And as you can see all that does is display the open door when you click on the image. I have not done any of the image mapping yet.
[Code]...
View 2 Replies
View Related
Jul 26, 2010
I'm trying to use javascript to load an image on a webpage when another image is clicked on, just like an image gallery and just like this except I don't need any text: [URL] I copied the example above but when I click on the smaller image to load the larger one it works for a fraction of a second (I can see the image load in the right spot), but then the browser goes to the URL of the image instead (showing it on a blank page).
[Code]....
View 13 Replies
View Related
Oct 28, 2011
I am trying to get the images on this page to revert back to the original photo after hover releases. I am assuming this is a simple fix, but I am no programmer and just did this in dreamweaver.[URL]
View 1 Replies
View Related
Nov 24, 2005
I would like to know what code I need to add to the Javascript below so that the images displayed will show a "<back and next button>" under each image, like on: http://www.msn.com Code:
View 4 Replies
View Related
Oct 17, 2008
I have created a very simple gallery using javascript, which just has numbered links to different images.I wanted a gallery like ery simple I wasn't sure how to build the next and back buttons
View 13 Replies
View Related
Jul 26, 2011
I want to place some background images behind my navigation links using JQuery. I have spent hours Googling the most promising solution which do not work : And when I apply these solutions to my own code I come up with: $('ul li :eq(0)').css('background', 'url(../images/home_icon.gi)');
View 2 Replies
View Related
Nov 16, 2010
Am just starting a new site and this morning noticed my header background image (logo) was missing.
Started out with normal CSS/HTML navigation menu.
www.westernwebdesign.com.au/pelican/index.html
Then I added a Vista buttons navigation menu:
http://www.westernwebdesign.com.au/p...cal/index.html
and the logo was gone. Not exactly sure at what point it disappeared yesterday as I didn't notice it missing until this morning. The navigation is about the only point of difference so I think this is the issue but have no idea why.
View 3 Replies
View Related
Oct 11, 2011
I have an onclick that does things and changes the className of my 'logo' div. All of the background images for div id 'logo' are styled by external CSS. A button I setup with addEvent alerts the className of 'logo' correctly but the 'logo' background doesn't change?index.css
Code:
#logo { position:absolute; left:0%; top:0%; width:99.8%; height:24%; background-color:#fdd841;
[code]....
View 10 Replies
View Related
Jan 18, 2010
Im looking to basically have an image which is a button with a value, and when i click the image, it gets replaced by another image with a different value. when clicked again it would return to the original image and value..Is this possible? and if so, please help cos im terrible at javascript!
View 3 Replies
View Related
Jun 9, 2010
$('.collapse').click(
function(){
/*THIS*/ $('#loadingSymbol').css('background-image','url("ajax-loader.gif")');
triggerReset();
$('.identRow').each(
[Code]...
But /*THIS*/ and /*THAT*/ never happen. Is there a way of doing a callback, so that when the background image has changed, do the below functions. Then end with changing it to nothing again?
View 6 Replies
View Related
May 5, 2010
I have a gallery that has back/next links below the main image, but I want them to be on each side of the image instead.
My current code looks like this:
Code:
<center>
<br class='clearit' />
<div id="main_image_wrapper">
[Code]...
I'm just not sure how to best do this. And I want the links centered to the height of the image.
View 5 Replies
View Related