I have a page in PHP where I want to implement a JavaScript alert for when the user clicks the "Create a call" menu to return a message to the user. I did the implementation using the alert (), however the alert returns when the page is updated and it is not quite what I want the alert () to do on the page.
This is my PHP.
// Create ticket
if (Session::haveRight("ticket", CREATE)) {
$menu['create_ticket']['id'] = "menu2";
$menu['create_ticket']['default'] = '/front/helpdesk.public.php?create_ticket=1';
echo '<script type="text/javascript">alert("Retorne uma mensagem para o usuário ao clicar!");</script>';
$menu['create_ticket']['title'] = __s('Create a ticket')
$menu['create_ticket']['content'] = array(true);
}
Because the code exceeds the character limit, I'll post the full page code below.
Link: Full Code
Source code of the page generated in HTML.
<!DOCTYPE html>
<html>
</script>
<a href="#" onclick="$('#loadbookmark').dialog('open');">
<img src="/glpi/pics/bookmark.png" title="Carregar um favorito" alt="Carregar um favorito" class="button-icon">
</a>
</li>
<li id="help_link">
<a href="http://glpi-project.org/help-helpdesk" target="_blank" title="Ajuda">
<img src="/glpi/pics/help.png" title="Ajuda" alt="Ajuda" class="button-icon">
</a>
</li>
</ul>
</div>
<div id="c_recherche"></div>
</div>
<div id="c_menu">
<script type="text/javascript">
alert("Retorne uma mensagem para o usuário ao clicar!");
</script>
<ul id="menu">
<li id="menu1"><a href="/glpi/front/helpdesk.public.php" title="Home" class="itemP">Home</a>
</li>
<li id="menu2"><a href="/glpi/front/helpdesk.public.php?create_ticket=1" title="Cria um chamado" class="itemP">Cria um chamado</a>
</li>
<li id="menu3"><a href="/glpi/front/ticket.php" title="Chamados" class="itemP">Chamados</a>
</li>
<li id="menu4"><a href="/glpi/front/reservationitem.php" title="Reservas" class="itemP">Reservas</a>
</li>
<li id="menu5"><a href="/glpi/front/helpdesk.faq.php" title="FAQ" class="itemP">FAQ</a>
</li>
</ul>
<script type="text/javascript">
< /html>
But I am not able to implement the function that calls the alert for only the item in this menu and not for the entire page. Could someone help?