2
I would like to know the method of editing the page and leave the content I edited fixed there forever, as if it were a post.
I’ve tried that already:
<style type="text/css">
.aprovado{
background-color: #060;
color: #FFFFFF;
}
.reprovado{
background-color: #f22;
color: #E2E2E2;
}
</style>
< script type="text/javascript" src="jquery-min.js"></script>
< script type="text/javascript">
$(function(){
$("#btn").click(function(){
$("#resposta").removeClass();
var nome = $("#txtnome").val();
var n1 = parseFloat ($("#txtn1").val());
var n2 = parseFloat ($("#txtn2").val());
var media = (n1 + n2) / 2;
$("#resposta").html(nome + ", " + media);
if(media >= 7){
$("#resposta").addClass("aprovado");
}else{
$("#resposta").addClass("reprovado");
}
});
});
</script>
<h3>Ver Dados do Aluno</h3>
<form>
Nome: <input type="text" name="nome" id="txtnome" />
<br /><br />
Nota1: <input type="text" name="n1" id="txtn1" />
<br /><br />
Nota2: <input type="text" name="n2" id="txtn2" />
<br /><br />
<input type="button" value="Enviar Dados" id="btn" />
</form>
<div id="resposta"></div>
It works, more when updating the page some, but how do I save the changes only using AJAX and jQuery?
It’s unclear what you’re asking. Elaborate, or your question will probably be closed. What exactly is your problem? What have you tried?
– elias
Could someone really help, it’s urgent
– Junior CT
Ajax serves to make client-server requests, when it changes the css class through a function, it runs only in the browser, and when you reload, it will go back to normal, which is programmed only in html. Find out the difference between running on the client side and on the server side. What you posted has nothing to do with ajax, only Jquery.
– Marcelo Aymone
You want to set a change made by the user on the page or by you in the code?
– Samir Braga
By the user, it will be in the admin panel will have the option to edit contents of a page, it clicks on specified content, type the new text to be shown, and then gets fixed on the page.
– Junior CT
You cannot do this only with javascript/jquery. You need a language running on the server, and possibly a database.
– bfavaretto
Database is no problem, more what kind of language do you mean? I currently know js,css,html,python and php.
– Junior CT
Python and php serve. You need a webserver, which receives what has been modified and saves the result (on disk or in a comic).
– bfavaretto
Okay, very helpful, thank you.
– Junior CT