473,399 Members | 3,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Passing array index value from img src trigger

I have googled everywhere but cannot find a solution.
Hopefully someone can help me here!?

By clicking a trigger image, I want to also pass an index value to my object inside my document.write text array and image array.
Simply adding ?xx=1 to the clicked img src does not work.
There must be some work-around that will succeed.
Passing this index value will save a lot of repetitious coding.
Thanks for any help!

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html>
  2. <html><head><title>PopupOverlay</title>
  3. <script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>
  4. <style>
  5. a:active {
  6.     outline:none;
  7. }
  8. :focus {
  9.     -moz-outline-style:none;
  10. }
  11. .simple_overlay {
  12.     display:none;
  13.     z-index:10000;
  14.     background-color:#fff;
  15.     width:260px;
  16.     min-height:300px;
  17.     border:1px solid #666;
  18.     -moz-box-shadow:0 0 90px 5px #000;
  19.     -webkit-box-shadow: 0 0 90px #000;
  20. }
  21. #triggers {
  22.   text-align:left;
  23.   }
  24. #triggers img {
  25.   cursor:pointer;
  26.   margin:0 5px;
  27.   background-color:#333;
  28.   border:1px solid #ccc;
  29.   padding:2px;
  30.   -moz-border-radius:4px;
  31.   -webkit-border-radius:4px;
  32.   }
  33. .details {
  34.   position:absolute;
  35.   top:15px;
  36.   right:15px;
  37.   font-size:15px;
  38.   color:#000;
  39.   width:220px;
  40.   }
  41. .details h3 {
  42.   color:#000;
  43.   font-size:17px;
  44.   }
  45.   </style>
  46. </head>
  47. <body>
  48.  
  49. <div id="triggers" class="noprint">
  50.   <img src="red.png?xx=1" rel="#mies1"/><BR>
  51.   <img src="green.png?xx=2" rel="#mies1"/><BR>
  52. <img src="blue.png?xx=3" rel="#mies1"/><BR>
  53. </div>
  54.  
  55. <script language="JavaScript">
  56. var myimages=new Array()
  57. myimages[1]="banana.png"
  58. myimages[2]="apple.png"
  59. myimages[3]="orange.gif"
  60. </script>
  61.  
  62. <script language="javascript">
  63. var info = new Array();
  64. info[1] = "Audi";
  65. info[2] = "Volvo";
  66. info[3] = "BMW";
  67. </script>
  68.  
  69. <div class="simple_overlay" id="mies1">  
  70.   <div class="details">
  71.     <h3>Heading</h3>
  72.     <script language="JavaScript">
  73. document.write('<img src="'+myimages[xx]+'">')
  74. </script>
  75.  
  76. <BR><B>Topic</B><BR>
  77.  
  78. <script language="javascript">
  79. document.write(info[xx])
  80. </script>
  81.   </div>
  82. </div>
  83.  
  84. <script>
  85.   $(document).ready(function() {
  86.       $("img[rel]").overlay();
  87.     });
  88. </script>
  89. </body>
  90. </html>
Dec 3 '12 #1
1 2280
Dormilich
8,658 Expert Mod 8TB
when using document.write() after the page load (e.g. by executing it when you clicked on an image) it will cause your whole page to be destroyed.

the original problem with the click is, that you don’t have a click handler assigned.
Dec 3 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Raju V.K | last post by:
I am developing a web site which requires a set og unique values be transferred between pages and server many times. There fore i decided to put the values in an array so that only one reference to...
4
by: PhilC | last post by:
Hi Folks, If I have an array holding a pair of numbers, and that pairing is unique, is there a way that I can find the array index number for that pair? Thanks, PhilC
3
by: Timmy | last post by:
I'm working on a simple click-through image gallery and I have images with captions in two arrays like this: var current_value="0"; var images = new Array ("photo01.jpg", "photo02.jpg",...
6
by: DeepaK K C | last post by:
Could anybody tell me how to pass array to a function by value? -Deepak
8
by: Joe Rattz | last post by:
Ok, I can't believe what I am seeing. I am sure I do this other places with no problems, but I sure can't here. I have some code that is indexing into the ItemArray in a DataSet's DataRow. I...
3
by: shobu | last post by:
passing array checkbox value and update the database <?include 'dbconnect.php'; error_reporting(0);$update_qr="update...
4
by: e_matthes | last post by:
Hello everyone, I have no trouble looping through an array using foreach. To keep track of the index, I set a variable before the loop and increment it in the loop: $index = 0; foreach...
14
by: Abhi | last post by:
I wrote a function foo(int arr) and its prototype is declared as foo(int arr); I modify the values of the array in the function and the values are getting modified in the main array which is...
1
by: cnsabar | last post by:
Hi., I need to set my array index start value "1" instead of "0".. Is it possible in perl... Can anyone help me reg. this. Thanks,
1
by: Sippeangelo | last post by:
Well I have a string with a couple of words. "Blah hello smart" They get divided up into an array like so: = "Blah" = "hello" = "smart" Now if the string is only "Blah" I only get one...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.