<div id="principal">
<div class="col-md-1"></div>
<div class="col-md-12">
<h1></h1>
</hr>
<div id="cambiante" class="col-md-12">
<div class="row" style="padding:10px;">
<div class="col-md-12">
<h2>Alta en Newsletter</h2>
<div class="row">
<div class="col-md-12">
<div class="col-md-6">
<div class="col-md-3">
<label>Email</label>
</div>
<div class="col-md-3" style="width:100% !important;">
<input style="width: initial !important;" id="campoAltaEmail" name="campoAltaEmail" type="text" placeholder="Escriba aquà su email" class="form-control input-md" required autofocus />
</div>
</div>
<div class="col-md-6">
<button id="botonAltaNewsletter" type="button" onclick="altaNewsletter()" class="btn btn-block btn-primary">
Dar de Alta
</button>
</div>
</div>
</div>
</hr>
<h2>Baja en Newsletter</h2>
<div class="row">
<div class="col-md-12">
<div class="col-md-6">
<div class="col-md-3">
<label>Email</label>
</div>
<div class="col-md-3" style="width:100% !important;">
<input style="width: initial !important;" id="campoBajaEmail" name="campoBajaEmail" type="text" placeholder="Escriba aquà su email" class="form-control input-md" required autofocus />
</div>
</div>
<div class="col-md-6">
<button id="botonAltaNewsletter" type="button" onclick="bajaNewsletter()" class="btn btn-block btn-primary">
Dar de Baja
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
function loadPrincipal() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("principal").innerHTML = xhttp.responseText;
}
};
xhttp.open("GET", "/newsletter/menuAdmin.php", true);
xhttp.send();
}
function altaNewsletter() {
var campoAltaEmail = document.getElementById('campoAltaEmail').value;
if (campoAltaEmail != "") {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("cambiante").innerHTML = xhttp.responseText;
}
};
xhttp.open("POST", "/newsletter/controlNewsletter.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("campoAltaEmail=" + campoAltaEmail + "&altaNewsletter=1");
}
}
function bajaNewsletter() {
var campoBajaEmail = document.getElementById('campoBajaEmail').value;
if (campoBajaEmail != "") {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("cambiante").innerHTML = xhttp.responseText;
}
};
xhttp.open("POST", "/newsletter/controlNewsletter.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("campoBajaEmail=" + campoBajaEmail + "&bajaNewsletter=1");
}
}
</script>