Look like this:
<html>
<head>
<meta charset="UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script></head><body><scripttype="text/javascript">
$(document).ready(function() {
$('#radioA').click(function() {
var data = 'id=aleaa';
$.get('aleatoria.php', data, function(response){
$('#dv').html(response);
});
});
$('#radioB').click(function() {
var data = 'id=aleab';
$.get('aleatoria.php', data, function(response){
$('#dv').html(response);
});
});
});
</script>
<div id="dv"></div><br/>
<input type="radio" name="group1" value="aleatoria" id="radioA"> aleatório A<br>
<input type="radio" name="group1" value="aleatoria" id="radioB"> aleatório B<br>
<!--<button id="buton">Click</button>-->
</body>
and create a random.php file like this:
<?php
if($_GET["id"] == "aleaa")
{
$palavras = array('Língua','Linguagem');
$aleatorio = rand(0,1);
echo $palavras[$aleatorio];
}
elseif($_GET["id"] == "aleab")
{
$palavras = array('Idioma','Dialeto');
$aleatorio = rand(0,1);
echo $palavras[$aleatorio];
}
?>
jquery makes a GET in the random.php file if the parameter (? id = alea) is correct it takes the random word it generated. If the answers were satisfactory, I ask you to score:)