Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder che_anj's Avatar
    Join Date
    Aug 2006
    Location
    Philippines
    Posts
    157
    Thanks
    12
    Thanked 3 Times in 3 Posts

    anyone can check my code.

    The purpose of creating this code is when I click the link which is the $row[employer_name] the said (FillAll $row[employer_name will be pass to the textbox of the parent window) and the second is by clicking the said the $row[employer_name] it will change the link.


    PHP Code:
    echo "<a href='javascript:FillAll(\"$row[employer_name]\",\"$row[employer_id]\");' 
    '"
    ; echo $_SERVER["PHP_SELF"]; echo '?click=searchcomp.php&empid='.$row['employer_id']."'
    >$row[employer_name]</a>"

    by just using below alone will work
    PHP Code:
    echo "<a href='javascript:FillAll(\"$row[employer_name]\",\"$row[employer_id]\");'>$row[employer_name]</a>"
    and also with this will also work

    PHP Code:
    echo "<a href=
    '"
    ; echo $_SERVER["PHP_SELF"]; echo '?click=searchcomp.php&empid='.$row['employer_id']."'
    >$row[employer_name]</a>"

    but combing the two wont work anymore.. could anyone tell me why..


    tnxxx.

  • #2
    Banned
    Join Date
    Apr 2007
    Posts
    428
    Thanks
    29
    Thanked 5 Times in 5 Posts
    You don't need 3 echoes there. Just one, and follow the little white rabbit...

  • #3
    Regular Coder che_anj's Avatar
    Join Date
    Aug 2006
    Location
    Philippines
    Posts
    157
    Thanks
    12
    Thanked 3 Times in 3 Posts
    i try this but its not working

    echo "<a href='javascript:FillAll(\"$row[employer_name]\",\"$row[employer_id]\");'
    '"$_SERVER['PHP_SELF']"?click=searchcomp.php&empid=".$row['employer_id']."'
    >$row[employer_name]</a>";
    Last edited by che_anj; 08-07-2007 at 04:24 PM. Reason: add

  • #4
    Senior Coder TheShaner's Avatar
    Join Date
    Sep 2005
    Location
    Orlando, FL
    Posts
    1,126
    Thanks
    2
    Thanked 40 Times in 40 Posts
    You want the link opened and the javascript function to be called all in one click, so I think you're looking for this:
    PHP Code:
    echo "<a href='" $_SERVER["PHP_SELF"] . "?click=searchcomp.php&empid=" $row['employer_id'] . "'
     onclick='FillAll(\"" 
    $row['employer_name'] . "\",\"" $row['employer_id'] . "\")'>" $row['employer_name'] . "</a>"
    You had two problems:
    1) In an href, you can't have both a link and a javascript call. You have to do one or the other.
    2) You were swapping out " and ' off and on. If you start a string using ", then make sure that the " is used to open and close the string.

    @Matak:
    The three echoes weren't causing the error. He can use echoes instead of linking each string with a . operator, but it's just generally messier.

    -Shane
    Last edited by TheShaner; 08-07-2007 at 04:30 PM.

  • Users who have thanked TheShaner for this post:

    che_anj (08-22-2007)

  • #5
    Banned
    Join Date
    Apr 2007
    Posts
    428
    Thanks
    29
    Thanked 5 Times in 5 Posts
    White little rabit just ran away..

    You need more help than just the one with syntax..

  • #6
    Regular Coder che_anj's Avatar
    Join Date
    Aug 2006
    Location
    Philippines
    Posts
    157
    Thanks
    12
    Thanked 3 Times in 3 Posts
    Great! Thanks TheShaner for your help.. It works now.. thanks a lot......

  • #7
    Banned
    Join Date
    Apr 2007
    Posts
    428
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by TheShaner View Post
    @Matak:
    The three echoes weren't causing the error. He can use echoes instead of linking each string with a . operator, but it's just generally messier.

    -Shane
    Yes, but i thought that this forum isn't intended to be a problem solver, but a path finder..

    j/k, from all this rabbits i see, i just can't think straight


  •  

    Posting Permissions

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