Skip to content

Instantly share code, notes, and snippets.

@fchevitarese
Created October 3, 2015 01:17
Show Gist options
  • Save fchevitarese/9161d7f5305d90fbb306 to your computer and use it in GitHub Desktop.
Save fchevitarese/9161d7f5305d90fbb306 to your computer and use it in GitHub Desktop.
add_proc.js
/** **
* Fun��o respons�vel por remover os campos de procedimentos.
* Somente ativo se for diferente de consulta ;)
*/
$(function() {
//@TODO --> Verificar quantidade limite de procedimentos ...
//@TODO --> N�o criar box se descri��o estiver vazia =D
//fadeout selected item and remove
$('.remove').live('click', function() {
$(this).parent().fadeOut(300, function(){
$(this).empty();
//totalProcedimentos--;
$('#qtdProcedimentos').val( parseInt($('#qtdProcedimentos').val()) - 1 );
if ($('#qtdProcedimentos').val() == '0')
{
$('#qtdProcedimentos').val( '' );
}
return false;
});
});
//add input
$('button#btnAdd').click(function() {
if ( $('#txtBuscaProcedimento').val() != '' ) {
var options = '<p><b>&nbsp;&nbsp;Procedimento:</b>&nbsp;&nbsp;<input type="text" name="txtProcedimento' + totalProcedimentos + '" id="txtProcedimento' + totalProcedimentos + '" size="150" class="input-xlarge" readonly="readonly" value="' + $('#txtBuscaProcedimento').val() + '"/> Quantidade: <input class="input-mini-mini" type="text" name="qtdSolicitada' + totalProcedimentos + '" id="qtdSolicitada' + totalProcedimentos + '" size="3" value="1" /> <button class="remove" type="button" id="btnRemove" name="benRemove">Remover</button></p>';
$(options).fadeIn("slow").appendTo('#extender');
totalProcedimentos++;
$('#txtBuscaProcedimento').val('');
$('#txtBuscaProcedimento').focus();
if ($('#qtdProcedimentos').val() == '') {
$('#qtdProcedimentos').val( 1 );
}
else {
$('#qtdProcedimentos').val( parseInt($('#qtdProcedimentos').val()) + 1 );
}
}
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment