Announcement

Collapse
No announcement yet.

php link + java?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • php link + java?

    Hi folks,

    I'm trying to add a java popup window on a php link but it doesn't work:


    Hyplink itself:
    Code:
    <a href="index.php?site=profile&amp;id='.getuserid($name).'">

    Together:
    Code:
    <a href="javascript:popUpProfile('index.php?site=profile&amp;id='.getuserid($name).'"')">
    If I could remove -> ' <- in between the brackets it should be fine but without those and -> '.getuserid($name).'" <- either won't work.

    A way to work around this?

  • #2
    Good afternoon,

    I am confused, surely by putting the single quote characters around the getuserid function you are simply creating a string literal rather than invoking the function getuserid.

    Now I am confused by what this function does, is it your own javascript function, or are you trying to invoke a php function serverside?

    Bye

    Ian
    Forums are about debating pleasantly not agreeing.

    Comment


    • #3
      Hi Karimali,


      echo "<a href=\"javascript:popUpProfile('index.php?site=pro file&amp;id=".getuserid($name)."')\">";
      The above should work fine.
      Webhosting.UK.com || cPanel VPS Hosting || Reseller Hosting

      Sales: 0808-262-0855
      Support: 0800-612-8725
      International: +44 191 303 8191

      Comment


      • #4
        Originally posted by IanSmithISA View Post
        Good afternoon,

        I am confused, surely by putting the single quote characters around the getuserid function you are simply creating a string literal rather than invoking the function getuserid.

        Now I am confused by what this function does, is it your own javascript function, or are you trying to invoke a php function serverside?

        Bye

        Ian

        Code:
        '.getuserid($name).'"')"
        gets a unique ID number for a user. Not my code, I use a CMS.

        Thanks Dan, I'll give it a try!

        Comment


        • #5
          Sorry Dan I'm having problems putting the code you provided and this one together:

          Code:
          <td><a href="?site=profile&amp;id='.getuserid($clan1).'" target="_top">'.$clan1.'</a></td>

          Comment


          • #6
            Try this. I'm sure it will work.

            [PHP]
            echo "<td><a href=\"?site=profile&amp;id=".getuserid($clan1)."\ " target=\"_top\">$clan1</a></td>";
            [/PHP]
            Webhosting.UK.com || cPanel VPS Hosting || Reseller Hosting

            Sales: 0808-262-0855
            Support: 0800-612-8725
            International: +44 191 303 8191

            Comment


            • #7
              Well that didn't work and this did work:

              Code:
              echo "<td><a href="?site=profile&amp;id='.getuserid($clan1).'"\" target=\"_top\">'.$clan1.'</a></td>";
              It needed the quotes and I had to get rid of the backslash after the hypertext reference, but this still won't work with the java:

              Code:
              echo "<td><a href="javascript:popUpProfile('?site=profile&amp;id='.getuserid($clan1).'"'\" target=\"_top\">'.$clan1.'</a></td>";
              Code:
              '.getuserid($clan1).'
              needs the single quotes aswell as the javalink which is causing the page to break.

              Comment


              • #8
                Well I can't see how the first one would work. I'd have something like

                [php]echo "<td><a href=\"?site=profile&amp;id=".getuserid($clan1)."\ " target=\"_top\">$clan1</a></td>";[/php]

                PHP variables are expanded in double quotes but not in single quotes.

                So to get rid of the escaped double quotes

                [php]echo '<td><a href="?site=profile&amp;id='.getuserid($clan1).'" target="_top">'.$clan1.'</a></td>';[/php]

                but this means escaping the single quotes in the Javascript (not Java - that's something completely different)

                So my best effort would be:

                [php] echo '<td><a href="javascript:popUpProfile(\'?site=profile&amp; id='.getuserid($clan1).'\')" target="_top">'.$clan1.'</a></td>';[/php]
                Last edited by black-dog; 10-12-09, 11:59 AM.
                black-dog
                4theweb.co.uk Web stuff
                slipperyhill.co.uk Band

                Comment


                • #9
                  Sorry I didn't get back to you black-dog

                  Code:
                  javascript:popUpProfile(\'?site=profile&amp;id='.getuserid($clan1).'\')
                  worked perfectly!

                  thanks alot.

                  Comment


                  • #10
                    That's nice to know. It's easy to make a mistake when you are writing code when you can't test it and keeping track of braces and quotes, even with syntax highlighting, can be difficult.
                    black-dog
                    4theweb.co.uk Web stuff
                    slipperyhill.co.uk Band

                    Comment

                    Working...
                    X