www.webdeveloper.com
Results 1 to 5 of 5

Thread: how to include a second "onclick event"

  1. #1
    Join Date
    Mar 2011
    Posts
    39

    how to include a second "onclick event"

    hello

    I have a website under Joomla and I need to include the follow code:

    Code:
    onClick="_gaq.push(['_trackEvent', 'Link', 'Click', 'ListingClaimButton']);"
    ...inside the follow code of a specific php file:

    Code:
                return '<span id="jr_claimImg'.$listing_id.'" class="jrButton jr_claimListing" title="'.__t("Claim This Business", true).'" onclick="s2Alert(\''.__t("Please register to claim this business",true).'\');">'. __t("Claim This Business", true).'</span>';
    I tried several combination but none work and I get always an error. This is probably due to the fact another "Onclick event" is present in the code and I do not see how to include it correctly...

    Unfortunately I do not have any PHP knowledges so is not easy...

    Somebody have an idea about the correct syntax to use ???

    thank for any suggestions

    cheers

  2. #2
    Join Date
    Dec 2005
    Posts
    2,984
    You can only have one onclick attribute, you just need to separate the function calls within the attribute.

    HTML Code:
    onclick="s2Alert(\''.__t("Please register to claim this business",true).'\'); _gaq.push(['_trackEvent', 'Link', 'Click', 'ListingClaimButton']);"
    I've switched careers...
    I'm NO LONGER a scientist,
    but now a web developer...
    awesome.

  3. #3
    Join Date
    Mar 2011
    Posts
    39
    thank for reply...

    Yes I have already try this code but this don't work and give me an error...

    I'm not sure but I suspect is the code I try to include need to be adapted because the single quote present here:

    Code:
    '_trackEvent', 'Link', 'Click', 'ListingClaimButton'
    ..give some problem...

    Or maybe it seem is because the PHP code is a bit unusual (for what I see because on some place the developer have add some backslash before quote) and is not possible to add my own Onclick Event without making some adaptation...

    Have you some more suggestions please ?

  4. #4
    Join Date
    Dec 2005
    Posts
    2,984
    Ah yeah, sorry, if this is in a single-quoted PHP echo statement, just stick \ before all the ' like this:

    Code:
    _gaq.push([\'_trackEvent\', \'Link\', \'Click\', \'ListingClaimButton\']);
    I've switched careers...
    I'm NO LONGER a scientist,
    but now a web developer...
    awesome.

  5. #5
    Join Date
    Mar 2011
    Posts
    39
    excellent it seem it was the solution because I don't get any more error. I just hope now the inclusion of my second Onclick Event will work like expected...

    thank a lot for your help...you made my day .-)

    all the best

    cheers

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles