Per
|
| Posted: 09/06/2002, 5:21 AM |
|
Presenting data in a grid containing email and web addresses, I want to provide these items with a link that will launch either the email client or a new browser window.
To do this I use the BeforeShowRow to insert the proper html.
But the string constants in PHP require quotes ("), example:
The datafield user_web in the form user_form (www.somesite.com) should be provided with this html,
<a href="http://www.somesite.com" target="blank">www.somesite.com</a>, when the page is loaded.
Writing an event (I use single quotes for php quotes to illustrate)
global $user_form
$user_form->user_web->SetValue('<a href=://"'. $user_form->user_web->Value. '" target="blank">'. $user_form->user_web->Value. '</a>';
So, can anybody help with telling me how I can escape the quote in the html
Thanks
|
|
|
 |
jjtoubia
|
| Posted: 09/06/2002, 6:53 AM |
|
To escape any characters, use the forward slash before that character.
Five things though regarding your statement you copied in. I don't know if you just quickly wrote your example statement in and missed these but if that is the code you used and you copied and pasted that statement in then you must have been experiencing a bundle of parse errors.
1) Your href line is incorrect. Your linked page would not appear correct because you have the :// before the quotations. Even if it did produce a clickable link, the result page in the Address Bar would appear as http://://www.somesite.com. So in other words, either do not add the :// or add http:// inside of the "" on the href variable.
2) You did not have any spaces before your concantation periods, only after.
3) You did not have the closing ) on your statement.
4) Your target variable for the href statement did not inlude the _ before the actual target. So instead of target="blank" it should appear as target="_BLANK". I use caps just for easy readability, caps is not required.
5) You did not add the semi-colon on the the end of your global statement. It should appear as global $user_form;
Your complete statement should look like...
global $user_form;
$user_form->user_web->SetValue('<a href=\"http://' . $user_form->user_web->Value . '\" target=\"_BLANK\">' . $user_form->user_web->Value. '</a>');
I always prefer double qoutes for PHP variables and single qoutes for HTML varaibles and other HTML output, so this is how I would write it...
global $user_form;
$user_form->user_web->SetValue("<a href='http://" . $user_form->user_web->Value . "' target='_BLANK'>" . $user_form->user_web->Value . "</a>");
Also, remember that HTML does not require qoutations, so you could always write the statement as...
global $user_form;
$user_form->user_web->SetValue("<a href=http://" . $user_form->user_web->Value . " target=_BLANK>" . $user_form->user_web->Value . "</a>");
Hope this helps!
|
|
|
 |
Per
|
| Posted: 09/06/2002, 11:00 AM |
|
Thanks,
also for your concern.
I made it work with double quotes for php and escaped double quotes for the html.
And i did not know it html worked without the quotes, and that worked too.
Using single quotes for the php loaded the absolute url as a folder to my own url, instead of a complete new Url. But I am satisfied now.
|
|
|
 |
|