Hi all,

I am able to run perfectly the following

<li><a href="javascript:ajaxpage('login.php', 'ajax');">Login</a></li>

But not the following

echo "Welcome Guest!<br><a href=javascript:ajaxpage('login.php', 'ajax');>"

I removed the " around the javascript:ajaxpage('login.php'); as it was giving me syntax error. But I am unable to cal login .php upon clicking Login.

I tried various combination of single quote and double quote but I think I am missing some fundamental rules of single and double quote combination....or may be something else.

Please make me understand.....

Thanks in advance
Gauri

you need to prefix the double quote with a slash if your echo command uses the double
quotes:

echo "Welcome Guest!<br><a href='#' onclick=\"javascript:ajaxpage('login.php', 'ajax');\">"

Here's another implementation:

echo 'Welcome Guest!<br><a href="#" onclick="javascript:ajaxpage(\'login.php\', \'ajax\');">'

and another (look up the sprintf() function on the php.net site if it is not obvious to you what it is doing):

echo sprintf('Welcome Guest!<br><a href="#" onclick="%s">'
              ,"javascript:ajaxpage('login.php', 'ajax');");

and another one:

//begin echoing UNTIL you find the line that STARTS with the matching MYLINK+semicolon
echo <<<MYLINK
               Welcome Guest!<br><a href="javascript:ajaxpage('login.php', 'ajax');">
MYLINK;
/*on the line above, there MUST be a newline IMMEDIATELY after the semicolon. You cannot have any blanks between the semicolon and the newline; otherwise you will get a runtime error.*/

Thanks Hielo. The last solution worked. Just to let you know that the first two solution telling the syntax mistake. I am novice so can't correct. What is <b></b> doing in last solution. I removed this as with out this also I am getting my result.


Warm Regards
Gauri

The first two are missing a semicolon at the very end to "end" the echo statement.
as for the <b></b>, I believe that is added by the text area where on this site (where I am typing this response). I've noticed it only when I click on "Toggle Plain Text" to get the plain text for editing, but if I click on it again (so it reverts to hmtl) it is invisible (since it IS HTML). Long story short, it should not have been there.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.