Click here to Skip to main content
       

JavaScript

 
GeneralRe: How do I hide a column using JQuery? PinprotectorAspDotNetDev8-May-13 8:17 
GeneralRe: How do I hide a column using JQuery? PinmemberJasmine25018-May-13 8:42 
GeneralRe: How do I hide a column using JQuery? PinmemberIlan Firsov8-May-13 19:51 
QuestionHTML Table to Export To Excel Pinmembershreeniwas kushwah6-May-13 20:06 
AnswerRe: HTML Table to Export To Excel PinmemberDennis E White7-May-13 5:18 
QuestionCode translate from AS to Delphi Pinmemberisaev.mail6-May-13 0:28 
AnswerRe: Code translate from AS to Delphi Pinmemberisaev.mail12-May-13 21:12 
QuestionUsing this.id PinmemberASPnoob5-May-13 7:40 
Hi all,
I am trying to pass the value inside of "this.id" from one function to another function but it's not working. Basically I am trying to grab the id of a thumbnail image which is inside anchor tags, by using "this.id" when they are clicked. Then I would like to display data related to the clicked thumbnail which are stored in an array, using innerHTML. I am using the AddEventListener property inside the script tags to listen for the onclick event thus I do not have the onclick property on my webpage. The following are my functions inside the script tags:
var songTitle =new Array("Title1", "Title2");
  function AddListeners()
    {
     if(window.addEventListener)
      {
       document.getElementById('A1').AddEventListener("click",Display_Info,false);
       document.getElementById('A2').AddEventListener("click",Display_Info,false);
       document.getElementById('A3').AddEventListener("click",Display_Info,false);
      }
     else if(window.attachEvent)
      {
       document.getElementById('A1').attachEvent("onclick",Display_Info);
       document.getElementById('A2').attachEvent("onclick",Display_Info);
       document.getElementById('A3').attachEvent("onclick",Display_Info);
      }
     }      
 
      function imgClicked(x)
      {
          var idClicked = x; //get thumbnail id      
          var newID = idClicked.substring(0,1); //subtract first character of thumbnail id        
          var convertedID = ParseInt(newID,10); //convert id to integer         
          return convertedID;          
      }
   
      function Display_Info()//passing in Parameter            
      {                 
          var A= this.id;
          var picID = imgClicked(A);
          document.getElementById('Title').innerHTML= songName[picID];                  
      }   
The following are anchor tags inside the body of my webpage:
<a href="#self"><img src=image1" id="A0"></a>
<a href="#self"><img src=image2" id="A1"></a>
<a href="#self"><img src=image3" id="A2"></a>
Please take a look to see why my script is not working. Any help is greatly appreciated, thanks in advance.
AnswerRe: Using this.id Pinmembertwseitex5-May-13 7:49 
GeneralRe: Using this.id PinmemberASPnoob5-May-13 8:01 
AnswerRe: Using this.id Pinmemberdusty_dex6-May-13 8:26 
QuestionSend data with XMLHttpRequest PinmemberMohamad Hoosein Fakhravary3-May-13 22:40 
QuestionRe: Send data with XMLHttpRequest PinmvpSandeep Mewara4-May-13 0:50 
AnswerRe: Send data with XMLHttpRequest PinmemberMohamad Hoosein Fakhravary4-May-13 11:08 
NewsForm builder using jQueryUI and Bootstrap [modified] PinmemberAnup Shinde3-May-13 2:10 
GeneralRe: Form builder using jQueryUI and Bootstrap Pinmemberdusty_dex3-May-13 4:56 
GeneralRe: Form builder using jQueryUI and Bootstrap PinmemberAnup Shinde3-May-13 5:05 
GeneralRe: Form builder using jQueryUI and Bootstrap PinmemberAnup Shinde3-May-13 5:06 
GeneralRe: Form builder using jQueryUI and Bootstrap PinmemberDennis E White3-May-13 5:59 
Questionloading image before loading video on page Pinmembermeena mehra30-Apr-13 2:17 
AnswerRe: loading image before loading video on page Pinmembertwseitex5-May-13 7:59 
QuestionI cant download the source code in the following projet PinmemberBaturay E.H.AHMAD27-Apr-13 9:17 
AnswerRe: I cant download the source code in the following projet PinmemberThePhantomUpvoter27-Apr-13 12:03 
QuestionjQuery Question PinmemberBobInNJ26-Apr-13 13:05 
AnswerRe: jQuery Question Pinmemberdusty_dex26-Apr-13 13:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.140905.1 | Last Updated 12 Sep 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid