Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Markup (HTML, XHTML, XML) _ Connecting the functionality of php code to html pop-up

Posted by: chrisj Dec 7 2022, 12:18 AM

This code is in the php file:

CODE
if (empty($error) && $_POST['set_p_v'] == 0){
    echo '<script type="text/javascript">alert("myPopup")</script>';
}


how do I connect that to a separate html file, that has this:


CODE
function myFunction() {
  var popup = document.getElementById("myPopup");
  popup.classList.toggle("show");
}


and this:

CODE
<span class="popuptext" id="myPopup">


and where does the pop-up message/text go?

I look forward guidance/assistance

Posted by: Christian J Dec 7 2022, 12:28 PM

QUOTE(chrisj @ Dec 7 2022, 06:18 AM) *

This code is in the php file:

CODE
if (empty($error) && $_POST['set_p_v'] == 0){
    echo '<script type="text/javascript">alert("myPopup")</script>';
}


That PHP script should create a javascript alertbox with the message text "myPopup" (provided the PHP script's IF conditions are true).

QUOTE
how do I connect that to a separate html file

What does "connect" mean here? I guess you could put the above PHP code in the HTML file. unsure.gif

But note that the javascript alertbox above has nothing to do with the SPAN element with the ID "popup", and neither is a javascript popup window --the latter are made like this: https://htmlhelp.com/faq/html/links.html#window-specify

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)