Look at it this way:
<html>
<head>
<meta charset="UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>
<script type="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 randomized.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 does a GET in the.php random file if the parameter(?id=Alea) is correct it takes the random word it generated. If the answers are satisfactory I ask you to point out :)
Hello, welcome to the OS in Portuguese. Try to explain your need better, including telling us what you already have. Consider doing the tour and also how to create a Minimum, Complete and Verifiable example.
– Bruno César
Have you tried using Jquery to become dynamic(when choosing one does the action A when choosing the other does the action B)
– Thalles Daniel
@Thallesdaniel How do I do this? I am zeroed in Javascript and jquery
– bee
Since you are from "0" see an example I made for you to have an idea of what you can do with jquery
– Thalles Daniel
How’s your code for generating random words
– Thalles Daniel