SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onclick and href

    Goal - have 16 pages representing a total of 26 alphabetical lists of magnolia clones; each page will have 1 to x links to a document to create popup including an image(s) of the magnolia flower. In order to not write the popup logic a couple hundred times, I am sending the magnolia id via the link to the popup logic where I use the php 'switch' routine to help create the desired popup. I want the popup to be approximately 425 x 530.

    Problem - have been trying 'onclick' within href. Have since seen in forum that one should (1) not use 'onclick' and (2) not use it within href.
    What behavior should I use instead of 'onclick' and how can I install a behavor to respond when a link is selected and only the intended link is 'clicked'.
    The gist of my last statement - presently when a link is selected, all of the 'onclicks' on that page react. Thus, when the first link (top link on the page) is selected, the popup logic receives the flag from the last link on the page. Therefore, I get the image for the last magnolia clone and not the selected clone.
    Thanks for any advice. I am not experienced in javascript.

  2. #2
    SitePoint Addict darkwater23's Avatar
    Join Date
    Nov 2005
    Location
    Omaha, NE
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LOL! What is a "Magnolia Clone"?

    Anyway, there is logic problem if all onClick react. There shouldn't be an issue using the onClick event of the <A> tag. It just depends on what you do when the click occurs. What I usually do in a case like this is to use javascript to create the new window only. On the HREF of the <A> tag, I would do this:

    Code:
    <a href="display.php?img=26" onClick="justOpenAWindowAtACertainSize();">Your Link</a>
    Then the display.php file would have some basic html for displaying an image. If you name all the images consistently, you could display them like this:

    Code:
    <img src="img_mag_<?php echo $_GET["img"]; ?>">
    If this makes no sense, then I probably don't understand what you are trying to do. Can you zip up and post one page that is an example of what you want to do?

  3. #3
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onclick and href

    Darkwater -
    Thanks for your assistance. Your answer was very helpful. Sorry for being so slow in expressing my appreciation as I have not been feeling well the last couple of weeks.

    BTW - a magnolia clone is merely a magnolia that has been asexually propagated by cuttings - not by seed. It is a named form.


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
  •