I have a code that inserts a textearea
field as a choice of input
radius. I would like to simplify this code making it use only JavaScript. It's 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;