I'm trying to create a messaging system that opens when you click the "New Message" button. I'm using HTML, PHP, and javascript.
I have a button set up with a container to append a textarea into. I am doing this with javascript DOM. This part I have no problem with, it is trying to get PHP inside javascript.
So let's say I have a variable:
<?php $my_name = "Eric" ?>
Would I be able to call this in javascript? If not, are there any any other ways to approach this?
Here is my full code:
HTML:
<html>
<head>
<link type="text/css" rel="stylesheet" href="message.css"/>
<script type="text/javascript" src="js/message.js"></script>
</head>
<body>
<div id="container"></div>
<button id="new_message" onclick="createMessage()">New Message</button>
</body>
</html>
CSS:
#container {
position: absolute;
height: 443px;
width: 743px;
border: 1px solid black;
border-radius: 0 0 20px 0;
margin-top: 100px;
}
Javascript:
function createMessage() {
var form = document.createElement("form");
form.name = "form_input";
form.method = "POST";
form.action = "messages.php";
container.appendChild(form);
var textarea = document.createElement("textarea");
textarea.name = "message_input";
textarea.cols = 84;
textarea.rows = 16;
textarea.id = "message_input";
container.appendChild(textarea);
};
I'm trying to do something similar to Facebook, that when you click on the messages button, a pop up box appears with php inside of it.
Can this be done the way I'm doing it with javascript or do I have to use something else?
Thanks for your help!