Sponsored Content
Top Forums Programming Javascript question: using the image button Post 302770496 by figaro on Saturday 16th of February 2013 01:49:07 PM
Old 02-16-2013
Javascript question: using the image button

I have javascript that I want to use to build up a dynamic array: the user clicks on one or more images and when clicking the Show button, the list of image names is displayed that the user clicked.

Code:
<script type="text/javascript">

var images = [];
images[1] = "https://www.unix.com/images/image01.jpg";
images[2] = "https://www.unix.com/images/image02.jpg";
images[3] = "https://www.unix.com/images/image03.jpg";
images[4] = "https://www.unix.com/images/image04.jpg";

for (var i in images)
   document.write('<input name="myImage' + i + '" id="myImage' + i + '" type="image" src=' + images[i] + ' alt="Add me..." onclick="add();" />');

var arr = [];

function add() {
   var inp = document.getElementById('myImage1');
   arr.push('myImage1');
   inp.value = '';
}

function show() {
   document.getElementById('container').innerHTML = arr;
}

</script>

<input type="button" onclick="show();" value="show" />
<div id="container"></div>

The code has a function add() which is obviously wrong, but has at least a sample value to show what happens when an image is clicked and subsequently the Show button.

How do I correct the code to only show the names of the images that the user clicked?


SOLVED:

Code:
<script type="text/javascript">

var images = [];
images[1] = "images/image01.jpg";
images[2] = "images/image02.jpg";
images[3] = "images/image03.jpg";
images[4] = "images/image04.jpg";

for (var i in images)
   document.write('<input name="myImage' + i + '" id="myImage' + i + '" type="image" src=' + images[i] + ' alt="Add me..." onclick="arr.push(\'myImage' + i + '\')" />');

var arr = [];

function show() {
   document.getElementById('container').innerHTML = arr;
}

</script>

<input type="button" onclick="show();" value="show" />
<div id="container"></div>


Last edited by figaro; 02-17-2013 at 07:34 AM.. Reason: Solved
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script for using the Back button and the Close button

Here's a question I have for anyone that might be able to help me: I can write a html script that will allow the user to return to the previous page using the back button, and I can write a script that will allow the user to return to the previous page using the close button, but...is there a... (1 Reply)
Discussion started by: mdgibson
1 Replies

2. UNIX for Advanced & Expert Users

Create an Ignite image on tape from Online IgniteUX image

Hi, (HP-UX 11.11) I need to create a tape image of an igniteUX image created on our igniteUX server. That is to say. I have a "Online" image of the igniteUX of the targeted system but I now need to copy it to a useable TAPE (igniteUX) image so i can build an other server from it that is not... (3 Replies)
Discussion started by: Andrek
3 Replies

3. Shell Programming and Scripting

need help with html button

Hello everyone, I am trying to implement an html button that will call a script and pass two arguments "perl script.pl website.com 1" this is for a search results page on a php spider called "sphider". the variable $url? is the url and Than needs to be one of the arguments in calling the script.... (0 Replies)
Discussion started by: mike171562
0 Replies

4. UNIX for Dummies Questions & Answers

Changing middle mouse button for pasting to right mouse button in cygwin rxvt

Hi, I'm using rxvt in Cygwin and I'm wondering how to change my mouse bindings from the middle button for pasting to the right button. The main reason why I want to do this is because my laptop doesn't have a middle mouse button. Thanks for any help! (2 Replies)
Discussion started by: sayeo
2 Replies

5. UNIX for Dummies Questions & Answers

onChange + javascript in perl CGI - question

Hello all, Am trying to include a onChange java script to my perl CGI application which uses POST method to upload files to file_server This is how I embedded javascript in the perl code that renders CGI application print qq| <script type="text/javascript" src="display.js"> </script>... (4 Replies)
Discussion started by: matrixmadhan
4 Replies

6. Shell Programming and Scripting

Simple question: Tcl button color

Hey, Can anyone tell me what is the default tcl button color is? I've already tried gray60/70/80/85/90/95. None are the same. Thanks, Phil. -----Post Update----- You can disregard this question, found the color in #E0DFE3 (0 Replies)
Discussion started by: Phi01
0 Replies

7. Solaris

Jumpstart Question: Update Image?

Hi everyone, We have a T5240 and noticed we were having issues booting the system using our jumpstart server (it seems as though we don't have the correct drivers for the nxge NIC) We thought we needed to update our jumpstart server image 9/10 Solaris SPARC image. Now I'm still learning... (4 Replies)
Discussion started by: Keepcase
4 Replies

8. Programming

Looking For the Best Way to Rotate an Image: JavaScript, PHP, HTML etc

Hey All, What I'm looking for is a way to rotate an image by non 90 degree angles (ie 90, 180, 270, 360). I am able to do it in PHP, but there are errors in the image, some pixels end up colored incorrectly and the image ends up resized and I lose transparency. I've done my share of searching on... (1 Reply)
Discussion started by: pmd006
1 Replies

9. Shell Programming and Scripting

matching image files to create one image

Hi, I have two sets of image files. Both sets have names A to Z but set 1 ends with .cdt.png and set 2 ends with .matrix.png. I want set 1 to match with set 2 if the names match (i.e. A.cdt.png will match with A.matrix.png) and with the convert image tool (program for images), it will merge the... (6 Replies)
Discussion started by: kylle345
6 Replies

10. Solaris

This must be the dumbest question ever posted -T5140 power button

I have a T5140 and cannot find the power switch -is there an on/off button? Good grief ! Thank you in advance. joe (3 Replies)
Discussion started by: joboy
3 Replies
pfsglview(1)						      General Commands Manual						      pfsglview(1)

NAME
pfsglview - Viewer for high-dynamic range images in pfs format SYNOPSIS
pfsglview [--h] [--v] DESCRIPTION
pfsview is a OpenGL/GLUT application for viewing high-dynamic range images. It expects pfs stream on the standard input and displays the frames in that stream one by one. DYNAMIC RANGE WINDOW
To show high-dynamic range data on a low-dynamic range monitor, pfsglview uses concept of a dynamic range window. The dynamic range window is the highest and lowest value that should be mapped to black and white pixel. Values above or below the window are clipped (see clipping methods below). The dynamic range window is displayed in pfsglview as a blue area on the dynamic range scale (second toolbox from the top). The window can be moved, shrunk and expended using a mouse or a keyboard. ZOOMING AND PANNING
To zoom image, the mouse can be dragged in vertical direction with the left button pressed. Pressing [space] button or pressing left mouse button above the statistic window (left-bottom corner) changes from zooming to panning modes and vice versa. To pan image, the mouse can be dragged in vertical and horizontal directions with the left button pressed. POPUP MENU OPTIONS
Zoom reset Set default zoom parameters. Zoom in Increase image (mouse dragging with left button pressed). Zoom out Decrease image (mouse dragging with left button pressed). Increase exposure Move dynamic range window into higher luminance values. Decrease exposure Move dynamic range window into lover luminance values. Extend dynamic range Extend dynamic range window. Shrink dynamic range Shrink dynamic range window Low dynamic range Set dynamic range window to <-1,1> range (log scale). Fit to dynamic range Set dynamic range windo to minimum and maximum luminance of a given image. Choose channel Change image data channel. Mapping method Change mapping method (see below for details). Next frame Display next image from the pipe. Previous frame Display previous image from the pipe. Histogram Switch on/off histogram window. Info Switch on/off info window. Save&Quit Send the visible LDR image (8-bits) to stdout and quit pfsglview. MAPPING METHODS
High-dynamic range data are usually better visualized using non-linear scale, for example a logarithmic or a power function. pfsglview offers several such scales, shown in popup menu. Gray-scale values for each mapping method are computed by the formulas: LINEAR: y = (x-min)/(max-min) GAMMA: y = [ (x-min)/(max-min) ]^gamma LOGARITHMIC: y = (log10(x)-log10(min))/(log10(max)-log10(min)) where y is the gray-scale value after mapping, x is an input HDR value, min and max are lower and upper bounds of the dynamic range window. EXAMPLES
pfsin memorial.hdr | pfsglview See the memorial image. pfsin memorial.hdr | pfsglview | pfsout memorial.jpg See the memorial image and save the clipped (8-bits) version to memorial.jpg (Save&Quit option from popup menu should be activated). SEE ALSO
pfsin(1) Please report bugs and comments to Radoslaw Mantiuk <radoslaw.mantiuk@gmail.com>. pfsglview(1)
All times are GMT -4. The time now is 10:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy