Olman Sánchez

All generations.

generate functionTue, 04 Jul 2023

a través de un input en HTML quiero hacer una búsqueda con el id en una tabla de phpmyadmin y que rellene con los datos de ese id otros inputs en el formulario

function buscar() { var id = $("#id").val(); $.ajax({ url: "buscar2.php", type: "POST", data: { id: id }, success: function(data) { $("#formulario")[0].reset(); var datos = JSON.parse(data); $("#id").val(datos.id); $("#nombre").val(datos.nombre); $("#precio").val(datos.precio); $("#cantidad").val(datos.cantidad); } }); }

Javascript
View
generate functionTue, 04 Jul 2023

que arrastre datos de una tabla y los rellenes en un formulario con solo escribir el ID

function getData(id){ var datos = getDataFromTable().filter(function(dato){ return dato.id === id })[0] document.getElementById('id').value = datos.id document.getElementById('name').value = datos.name document.getElementById('address').value = datos.address document.getElementById('phone').value = datos.phone document.getElementById('email').value = datos.email }

Javascript
View
generate functionThu, 06 Jul 2023

Funcion para capturar un dato desde un input, que realize una consulta en la base de datos y que actualize los inputs con los datos obtenidos de la base de datos, que esto lo haga en tiempo real

$("#txtSearch").keyup(function () { var txtSearch = $("#txtSearch").val(); var criteria = 0; if (txtSearch.length > 0) { $.ajax({ type: "POST", url: "../AppServices/wsSearch.asmx/Search", data: "{'search':'" + txtSearch + "', 'criteria':'" + criteria + "'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { console.log(response); var data = response.d; if (data.length > 0) { var item = data[0]; $("#txtNombres").val(item.Nombres); $("#txtPaterno").val(item.APaterno); $("#txtMaterno").val(item.AMaterno); $("#txtEmail").val(item.Email); } else {

Javascript
View
generate functionThu, 06 Jul 2023

a través de un input en HTML quiero hacer una búsqueda con el id en una tabla de phpmyadmin y que rellene con los datos de ese id otros inputs en el formulario

function get_details(id) { $.ajax({ url: "http://localhost:8888/php_crud/get_details.php", type: "POST", //metódo de envío dataType: "html", //tipo de datos data: {id:id}, //de que parte del formulario viene el dato success: function(data) { //si la operación fue exitosa var response = $.parseJSON(data); //convierto la respuesta a objeto $("#name").val(response.name); $("#email").val(response.email); $("#address").val(response.address); $("#gender").val(response.gender); $("#age").val(response.age); } }); }

Javascript
View
generate functionMon, 05 Jun 2023

crear una tabla de amortización

function amortization($amount, $yearlyInterestRate, $termInYears) { $monthlyInterestRate = $yearlyInterestRate / 1200; $numberOfPayments = $termInYears * 12; $monthlyPayment = $amount * ($monthlyInterestRate / (1 - pow(1 + $monthlyInterestRate, -$numberOfPayments))); $balance = $amount; $interest = 0; $principal = 0; $totalInterest = 0; $totalPrincipal = 0; echo "Payment # \tInterest \tPrincipal \tBalance"; for ($i = 1; $i <= $numberOfPayments; $i++) { //calculate interest $interest = $monthlyInterestRate * $balance; //calculate principal $principal = $monthlyPayment - $interest; //deduct principal from remaining balance $balance -= $principal; //update totals $totalInterest += $interest;

PHP
View

Questions about programming?Chat with your personal AI assistant