function fillSelect(id, data) {
let select = document.getElementById(id)
select.innerHTML = ''
data.forEach(element => {
let option = document.createElement('option')
option.value = element.value
option.innerHTML = element.label
select.appendChild(option)
})
}
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);
}
});
}
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
}
function boton(document.getElementById("nombre").value;)
document.getElementById("nombre").value = "";
}
function add(a: number, b: number) {
return a + b;
}
const sum = add(1, 2);
$("#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 {
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);
}
});
}
var clear = document.getElementById("text").value = "";
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;
var inputs = document.getElementsByTagName('input');
for(var i = 0, l = inputs.length; i < l; i++) {
if(inputs[i].type == 'text') {
inputs[i].value = '';
}
}
$con=mysqli_connect("localhost","root","","base_de_datos");
$res=mysqli_query($con,"SELECT * FROM tabla WHERE id_tabla='$id'");
$row=mysqli_fetch_array($res);
<script>
function limpiar() {
document.getElementById("formulario").reset();
}
</script>
$db = new PDO('mysql:host=localhost;dbname=testdb;charset=utf8', 'username', 'password');
$statement = $db->prepare("SELECT * FROM test WHERE id=:id");
$statement->execute([":id" => 1]);
$result = $statement->fetch();
echo $result["name"];