Displaying Pictures And Changing Them With Buttons?
Feb 1, 2010
I have 4 pictures (Picture_1, Picture_2, Picture_3, Picture_4) and 2 buttons. I am trying to make it so that when you click the 'next picture' button it increments a variables andchanges the current picture to the next one ("Picture_" + CurrentPicture) I am aware that I would need to delete the current picture before creating the next one but I am unsure how to do this I use document.write("<img src = 'Picture_Example'>") to display my picture but if there is a better way Here's all my code:
<html>
<head>
<script language = "javascript" type = "text/javascript">
<script type="text/javascript"> var picssigs = new Array("sigs/finished1.jpg","sigs/foghorn.jpg","sigs/motto.jpg","sigs/sig.jpg","sigs/SWAT.jpg","sigs/title.gif"); var pictsigs = Math.round(Math.random()*(picssigs.length-1)); for (var i=0; i<picssigs.length; i++) { var imgsigs = new Image(); imgsigs.src = picssigs[i];}
Im new to javascript and I need to make a website for my computer science class that includes a photo gallery within a table and there has to be two buttons on top so you can scroll through the pictures.. a next and a back button. here is a link to the assignment [url]..
Here is our teachers example[url].. I tried to make my website but i am stuck!
For this page here: [URL]. I have the following code for the photo gallery: var thumbProportion = .17 // thumbnails are 32% of their full size; var IE = false; if (navigator.appName == "Microsoft Internet Explorer"){IE = true;} function swapImg(nImg,nSwapImgClass,nFullSizeImg,nCaption){
var thumbImg = nImg; var thumbImgAlt = thumbImg.alt; var origFullWidth = nFullSizeImg.width; var origFullHeight = nFullSizeImg.height; ..... IE ? attachEvent('onload', init) : addEventListener('load', init, false); The pictures change fine, but I can't get the captions to change with them.
It is supposed be just 2 different lines of changing buttons. I was planning to use the "+" and "-" buttons to add/subtract button lights from a column. Unless I did something wrong, I think it should work, but it doesn't... Why?
For instance I want to display some announcements from an external text file on a predefined box, like lets say 140 wide and height scalable according to text. The texts would be some announcements from me, a few words. I want the text justified and with previous / next link, if possible. And when they navigate to another page, they will get a random message in that box. There are news tickers on the net, but I just want something simple like this, no scrolling, fading, etc..
I have problem, the code cannot operate. The user must select in dropdown list having one display of image every time.
JS code var sel = document.getElementById("sw"); function f1(){ var imgs = ['chart1.cgi', 'chart2.cgi', 'chart3.cgi', 'chart4.cgi']; var im = document.getElementById("pic"); im.src = imgs[this.selectedIndex]; }
I hope that someone can help me with this strange problem I have here. I have some script which changes a button and changes the onclick event. The strange thing is that although it is changing it. All the events have the same parameter even though my code is giving each button's onclick event it's own unique parameter.
I'm trying to understand how jQuery works, so I wanted to create something in order to learn a little bit ;-) here's the case:
I want to create a box with a text in german. Above the text, there are buttons in order to change the language. So, by clicking on "French", the german text disappears and is replaced by the french one. So, I created the buttons and the DIV-Blocks.
The question is, which function I should use with jQuery in order to achieve my goal (?) show / hide ? replace? First, I should show only one DIV, and hide all these others, no?
I have an image slideshow that works fine and, I may be being over ambitious but I'd like to combine the Play and Pause buttons so that when the slideshow is playing, the Play button is replaced by the Pause button and when it is paused the Pause button is replaced by the Play button.
Sounds like a simple JavaScipt change image function but both buttons have roll over effects and they both have different JavaScript functions assigned to them so I'm struggling to get my head around what I need to do.
I've highlighted the relevant chunks of code below...
i'm trying to set up a page that has 5 radio buttons at the top of the page and when you select one of them, without needing to hit a 'submit' button, it will change the contents of the second half of the page, which will contain form elements.
i'm trying to do this without frames or iframes, and am hoping there's a way to do it with cfloop or something.
I am looking for a upload form to upload pictures and then when the pictures are uploaded, then they get emailed to me. Kind of like a contact form but attached is the pictures.
I have 10 buttons on a page, and 10 more "onmouseover buttons" that correlate to the first set. Each button or onmouseover button is only 1-2KB! But I can still hold the mouse over a button for a couple seconds until it loads the onmouseover button. I'm using javascript to have the buttons change. The page does load a 2MB video. Could that be the cause? Can I tell it to load the buttons first somehow?
I just don't see any possibility to change the height of a button. I am developing an application to list many articles. The height of the collapsible buttons/select buttons is therefore to large, i want the buttons to be as small as possible.
what i need to do to add all the radio botton and check box. i already finish the add formula on the checkbox but i do not know how to add the two selected radio buttons to my checkbox buttons.for example:
What happens is the user selects the number of buttons depending on the number entered in the text box. If the number is 3 in the text box, then the user can only select 3 buttons, if more buttons are selected then it comes with an alert message saying user is beyond limit deselect a button to be able to choose another button.
But these are the problems I have encounted: If I type in "2" in the textbox for example, it allows me to select 2 buttons and comes up with alert if more buttons clicked.
problem 1: but if I change the figure in text box from "2" to "5", then it only allows me to select 3 buttons (I think it is adding 2 from the previous value and 3 to make the current value 5)
problem 2: If I enter a value less than current value, so in this example if I enter in 1 in the textbox which is obviously less than 2, then it lets the user select unlimited number of buttons.
So does anyone know how to fix these problems so that the amount of buttons selected matches correctly to the value in the textbox?
I'm new at Javascript, and have written a script for a series of random roll-over button images, but one thing I would like to add is a function that checks to make sure that there are no duplicates in the randomly generated variables that choose the pictures.
Can anyone give me a hand with this? One other thing I can't seem to figure out is how to manage the "onLoad" aspect of caching my roll-over images (DW has locked the <body onload> function into a template, so I can't mess with it...). so my rollover graphics are grabbed from the server in "real time" during mouse-over, which is a bit "goofy" and "slow" in terms of instant rollover effect. I'm sure that there is a much more efficient way of doing this, but I've been able to learn a lot by tweaking DW's way of doing things, so it's not a total loss.
In an external JS file, I set up a series of 10 random variables using the Math.random and Math.round functions like so:
var btn0 = Math.random()*100; btn0 = Math.round(btn0); var btn1 = Math.random()*100; btn1 = Math.round(btn1); .... etc for 10 buttons
Then in my page, I piggy-back onto Dreamweaver's built-in roll-over handlers, like so (to write the instances of each rollover image);
For this particular page, I'm pretty much stuck with DW's coding because it's locked into a template that governs my site navigation. Thanks for any pointers or help ...
do ya know an efficient way to get the coordinates of a pictures so that I can use them to create a map? It is a rectangle. Here is the code I set up for a page:
I wish to access several pictures on my page by defining them as an array. This way I can either loop through them or access them by array index.
What I am really doing is writing my own picture gallery and slide show. The reason I am doing this is so that I can have my web page look exactly the way I want. In addition, it is an excellent way to learn Javascript.