×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Nov 2008
    Posts
    54

    how to pass own id to a function?? it not works here

    Hello everyone,

    this is my part of code
    Because I want to generate a box list,each list with a 'a' tag,which is showed by a picture. When u click this 'a' tag, it will trigger 'comeon' function to show the id of the specific box.

    var pokebutton=document.createElement("a");
    pokebutton.id='buttonpoke';
    pokebutton.setAttribute('href','javascript:void(0);');
    pokebutton.setAttribute('onclick','javascript:comeon(pokebutton.id);');

    function comeon(vadlue){
    document.getElementById("do").innerHTML=vadlue;
    }

    But it not works, without any output.

    In order to test I remove the parameter value, just call comeon to print some hard code. It works. It proved that I can't pass the id like' pokebutton.id' ,is it?

    Because it is used in box list, so I have to pass a variable,but not the static id directly.


    Who can Help me,? How can I pass this id of a tag?

  2. #2
    Nokia Developer Expert
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    833

    Re: how to pass own id to a function?? it not works here

    Hello,

    Try this out:

    Code:
    var bbId=0;
    function addHref(){
    	var pokebutton = document.createElement("a");
    	pokebutton.id = "buttonpoke_"+ bbId;
    	pokebutton.setAttribute("href", "#");
    	pokebutton.onclick = comeon;
    	pokebutton.innerHTML = "IMG placeholder";
    	bbId++;
    	
    	document.body.appendChild(pokebutton);
    }
    
    function comeon(e){
    	 alert("e.target.id="+e.target.id);
    }
    -Ilkka

Similar Threads

  1. How to pass argument in console EXE function?
    By SymbianTH in forum Symbian
    Replies: 10
    Last Post: 2013-11-13, 08:28
  2. SPP read() freeze on Nokia but works on SE and Motorola
    By lucho554 in forum Bluetooth Technology
    Replies: 6
    Last Post: 2009-07-29, 23:03
  3. Replies: 4
    Last Post: 2007-05-24, 04:06
  4. C-code..unable to make sis
    By Symbian_Neil in forum Symbian
    Replies: 9
    Last Post: 2006-12-02, 07:55
  5. Replies: 2
    Last Post: 2006-09-26, 03:58

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×