The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Connecting the functionality of php code to html pop-up
chrisj
post Dec 7 2022, 12:18 AM
Post #1





Group: Members
Posts: 9
Joined: 6-May 21
Member No.: 27,927



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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Dec 7 2022, 12:28 PM
Post #2


.
********

Group: WDG Moderators
Posts: 9,630
Joined: 10-August 06
Member No.: 7



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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th March 2024 - 04:05 PM