...

View Full Version : anyone can check my code.



che_anj
08-07-2007, 04:58 PM
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.




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


echo "<a href='javascript:FillAll(\"$row[employer_name]\",\"$row[employer_id]\");'>$row[employer_name]</a>";



and also with this will also work



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.

matak
08-07-2007, 05:13 PM
You don't need 3 echoes there. Just one, and follow the little white rabbit...

che_anj
08-07-2007, 05:17 PM
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>";

TheShaner
08-07-2007, 05:28 PM
You want the link opened and the javascript function to be called all in one click, so I think you're looking for this:

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

matak
08-07-2007, 05:28 PM
White little rabit just ran away..

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

che_anj
08-07-2007, 05:32 PM
Great! Thanks TheShaner for your help.. It works now.. thanks a lot...... :)

matak
08-07-2007, 05:38 PM
@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.. :D

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum