Results 1 to 6 of 6

Thread: Retrieve a value with onclick

  1. #1
    Join Date
    Dec 2008
    Posts
    150

    Retrieve a value with onclick

    With onclick no problem to display text in a tag. I use this:

    <img src="image.png" onclick="document.getElementById('disp').setTextValue('$tab[name_action]');">

    and it appears there:
    <span id="disp"> </ span>

    But I would like to get the result without a tag and can display it in my document php. I try to create a variable:

    onclick="var disp = document.getElementById('disp').setTextValue('$tab[name_action]');"

    but I can not see the result.
    Do you have any idea?

  2. #2
    Join Date
    May 2008
    Posts
    1,196

    Re: Retrieve a value with onclick

    Already there, in your var disp, you will at most result of the function. setTextValue () (just what framework elsewhere? .. Because I was not a standard JS!)

    A simple Code:

    Code:
    var disp = $tab [ name_action ] ;
    would be sufficient ...

    Secondly, I think that even if you ASSIGNED your variable in this way, its visibility will be limited to the management of the event ... In fact, "var" locates the variable block of code in which it is declared. To make global and thus usable simply turn the "var"

  3. #3
    Join Date
    Dec 2008
    Posts
    150

    Re: Retrieve a value with onclick

    I tested:
    onclick = "disp = $tab [name_action];
    but I can not display the $ disp

  4. #4
    Join Date
    May 2008
    Posts
    1,196

    Re: Retrieve a value with onclick

    Display where? When? How? ... Then, do not mix: $disp with existing JavaScript.

    This '$' in me have some suspicions: you do not want to get that value on the server side by chance?

    (And I still do not know what framework you use ... because, I repeat, setTextValue () is not a standard JS! .. I have an idea of the answer .. but I want to be sure you know what you manipulate! )

  5. #5
    Join Date
    Dec 2008
    Posts
    150

    Re: Retrieve a value with onclick

    I want to make an application facebook, when you click on an image I want to get the id of the image to insert a tag that does not code tags, I do not know how to explain it more simply.

    In any case thank you for your help.

  6. #6
    Join Date
    May 2008
    Posts
    1,196

    Re: Retrieve a value with onclick

    In fact, you want that, one way or another, information such as what "the user has clicked on the image "XYZ" is registered "some part" in the end, I guess, and send this information on the server side to be dealt with ...

    But I guess that you do not want to reload the page and therefore you do not want to submit the information immediately in a way "classic" (a simple form)

Similar Threads

  1. IE7 href + onclick - both happen
    By Ucchal in forum Software Development
    Replies: 5
    Last Post: 24-05-2010, 03:58 PM
  2. CSS Button onclick event href="#" onclick="
    By Cornnelius in forum Software Development
    Replies: 6
    Last Post: 14-05-2010, 11:20 PM
  3. Onclick event with DIV tag
    By ISAIAH in forum Software Development
    Replies: 5
    Last Post: 03-03-2010, 04:45 PM
  4. HTML/JavaScript/onclick
    By KADEEM in forum Software Development
    Replies: 4
    Last Post: 03-11-2009, 06:37 PM
  5. Onclick and Firefox3
    By Coolestman in forum Software Development
    Replies: 3
    Last Post: 02-09-2008, 02:46 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,926,467.75337 seconds with 17 queries