TinyMCE exec Command inside php loop - javascript

Trying to get an href with TinyMCE command function working but no luck. I used double and single quotes as well. Here is the original code
echo "<a href="javascript:;" onclick="tinyMCE.activeEditor.setContent('');tinymce.execCommand('mceInsertContent',false, document.getElementById('div_".$i."').innerHTML);
return false;">[Manage Marketing]</a>";

echo "<a href=\"javascript:;\" onclick=\"tinyMCE.activeEditor.setContent('');tinymce.execCommand('mceInsertContent',false, document.getElementById('div_".$i."').innerHTML);
return false;\">[Manage Marketing]</a>";

Related

including html tag in a php code, specifically dealing with href function inside a php block

enter the html code once a condition is satisfied but then i aim to use php values and html tags together.
tried tag etc and got most of the part in running just unable to deal with href beacuse it is referencing to some values.
not sure where to use "" or ``.
<?php.....
echo `Yes`;
?>
"yes" should work as a hyperlink but at the moment the php values are not processed that`s why no result.
You are using wrong sequence of quote
<?php
...
?>
<?php
echo '<a href="limitdatabase.php?Dropdown=' .
$_GET['Dropdown'].
';&search='.
$search_name .
';&wise='.
$_GET['wise'].
';">Yes</a>';
?>
and you should use single quote and not backtics for string
You are using incorrect concatenation. Whenever you want to add any PHP variable then you need to close the braces and need to start after PHP variable as below:
<?php
echo 'Yes';
?>
Also you should wrap Dropdown and wise in braces as it will not work directly in get as you have used. Hope it helps you!
You can use combination of html with php inside:
<a href="limitdatabase.php?Dropdown=<?PHP echo $_GET[Dropdown] . "&search="
. $search_name . "&wise=" . $_GET[wise]; ?>">Yes</a>
Also, you can input whole link in string:
<?php
$mylink = "limitdatabase.php?Dropdown=" . $_GET[Dropdown] . "&search=" . $search_name . "&wise=" . $_GET[wise];
?>
YES

PHP a href echo with span not functioning properly

I have the code
echo '<span class="imperial-username">';
echo'<a target="_blank" href="profile/'.$row['name'].'">'.$row['name'];'</a>';
echo'</span>';
which functions fine when i press the name it takes me to the profile. But if I click the image also above the name it will go to the person who is above on the list, as I have a list of links. And only goes to there profile if you click the name specifically.
Also all other links on the page seem to be not functioning properly and going to random profiles when pressed, the links are carrying over down the page or something is what I assume, maybe code not closed properly, but I see nothing that should be causing this.
You have a semicolon ; instead of a dot . in .$row['name'];'</a>';.
It is not a syntax error, because the instruction '</a>'; is valid but has just no effect.
please try this
echo '<span class="imperial-username">';
echo'<a target="_blank" href="profile/'.$row["name"]>'.$row["name"].'</a>';
echo'</span>';
echo '<span class="imperial-username">';
echo '<a target="_blank" href="profile/'.$row['name'].'">'.$row['name'].'</a>';
echo '</span>';

How to add ' to generated link in php

$output .= '<a class="dropdown-toggle has-category" data-toggle="dropdown" href="'.$this->getLink($menu).'" target="'.$menu['target'].'">';
I have php file with this code href="'.$this->getLink($menu).'"
its generates in html this href="https://www.myweb.com/"
Now i need to do it with onClick so that the output turned out like this
onclick="location.href='https://www.myweb.com'"
Changed php code onclick="location.href='.$this->getLink($menu).'"
and result is onclick="location.href=https://www.myweb.com"
Link not working cuz lacks '
Can someone help me?
Try this
onclick="location.href=\''.$this->getLink($menu).'\'">
Example:-
echo '<a onclick="location.href=\''.$this->getLink($menu).'\'">';
Can you add this escaped single quote: \'?
echo '...onclick="location.href='.$this->getLink($menu).'\'"...';
(I added the echo to complete the code example).

How to add a new line within JS confirm message to be shown on click of a link?

I'm trying to add \n but this breaks the onclick event – no message is popped up at all.
It works OK when I remove the \n character.
<?php
echo "<a href='logs.php?clear=true' onclick='return confirm(\"Are you sure:\n To delete this\");'>Clear</a>";
You need to use double backslashes, the first will be interpreted by PHP. Try this instead:
<?php
echo "<a href='logs.php?clear=true' onclick='return confirm(\"Are you sure:\\n To delete this\");'>Clear</a>";
Though you may want to use a heredoc instead:
<?php
echo <<< HTML
Clear
HTML;
Or, even better, use proper event binding like with jQuery:
<?php
echo <<< HTML
Clear
<script>
$("#clearconfirm").click(function(e) {
if (!confirm("Are you sure:\\n To delete this")) {
e.preventDefault();
}
});
</script>
HTML;

Write onclick method that has parameters in php print function

I'm having problems with writing an onclick method in php print in code below:
<?php print "<p><small> <a href='#' onclick='ajaxMenu('comments.php?news=".$fileContent['id']."');>".$number. " ".$text." </small> </a> </p>"; ?>
Given code doesn't work. I believe it's because of combination of single and double quotes in it. Can anyone help me to solve this?
You can escape " characters by having a forward slash \"
<?php echo( "This is a link" ); ?>

Categories

Resources