1
I have a code that inserts a field textearea
as a choice of input
radio. I would like to simplify this code by making it use Javascript only. Is it possible? Follow below:
HTML
<p>2.3 - Você estuda? </p>
<input type="radio" name="estuda" id="estuda" value="1" required=""> Sim
<input type="radio" name="estuda" id="estuda" value="2" required=""> Não
<div id="ret-ajax"></div>
Javascript
$('#estuda').change(function () {
var chars = (this.value);
$.post(URL + 'Ajax/pesquisa', {val: chars}, function (busca) {
$('#ret-ajax').html(busca);
});
});
Ajax
$char = $_POST['val'];
$body = '';
if($char == 1){
$body .= '<textarea name="curso" rows=4></textarea>';
}
elseif($char == 2){
$body .= '';
}
$retorno = $body;
Thanks friend, it worked perfectly.
– Eduardo Santos
You’re welcome @Eduardosantos. I’m glad you did
– Miguel