Спасибо, вот код файла
create_interview.php
<?php
if(isset($_POST['name']) && isset($_POST['hidden']))
$name = $_POST['name'];
$hidden = $_POST['hidden'];
foreach($_POST as $key => $value)
echo "POST parameter '$key' has '$value'"."<br>";
а это код файла
demo.html
<!DOCTYPE html>
<html>
<head>
<script src="jquery-3.1.1.js"></script>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<style type='text/css'>
#MyForm > label {
display: flex;
}
#MyButton {
border-color: #008a77;
margin-left: 500px;
width: 200px;
height: 50px;
}
#MyButton2 {
border-color: #008a77;
margin-left: 30px;
width: 200px;
height: 50px;
}
#MyButton3 {
border-color: #008a77;
margin-left: 30px;
width: 200px;
height: 50px;
}
/*#SendButton {display: none;}
#MyButton2 {display: none;}*/
</style>
<script type='text/javascript'>
function myQuestion() {
document.getElementById('SendButton').style.display = 'flex'
document.getElementById('MyButton2').style.display = 'inline'
var ol = document.createElement("label");
var txt = document.createElement("textarea");
var i=document.querySelectorAll('#MyForm textarea').length;
ol.innerHTML='Вопрос '+(i+1);
txt.name='Question'+i;
ol.appendChild(txt);
document.getElementById('MyForm').appendChild(ol);
}
function myAnswer() {
var ol2 = document.createElement("label");
var txt = document.createElement("textarea");
var i=document.querySelectorAll('#MyForm textarea').length;
ol2.innerHTML='Ответ '+(i+1);
txt.name='Answer'+i;
ol2.appendChild(txt);
document.getElementById('MyForm').appendChild(ol2);
}
function Send() {
var opros = prompt('Создайте имя опроса');
if (opros != null) {
//var doc= document.getElementsByName('hidden');
//var doc= document.getElementsByName('hidden')[0];
var doc = document.querySelector("#createInterview>[name='hidden']")
doc.value = opros.value;
document.getElementById('createInterview').submite();
} else {
Send();
}
}
</script>
</head>
<body>
<p>Click the button to make a BUTTON element.</p>
<button onclick="myQuestion()" id="MyButton">Вопрос</button>
<button onclick="myAnswer()" id="MyButton2">Ответ</button>
<button id="MyButton3" form="createInterview" onclick="Send()">Создать опрос</button>
<form id="MyForm" action="elements.php" method="post"><button id="SendButton">Отправить</button></form>
<form id="createInterview" method="POST" action="create_interview.php">
<input type="hidden" name="hidden" value="">
<p>Ваше имя: <input type="text" name="name" /></p>
<p><input type="submit" id="send" /></p>
</form>
</body>
</html>