Veronica20_qro
Veronica20_qro

Reputation: 85

how to send textbox's value by url

I have a form and i have to sent some values (values of textboxes) NOT by POST, I have to do it by GET.

This is my code:

    <a class="btn btn-warning btn-sm" href="insertcot.php?pais=document.getElementById('pais').value&proyecto=document.getElementById('proyecto').value&notas=document.getElementById('notas').value&formapago=document.getElementById('formapago').value&fechaentrega=document.getElementById('fechaentrega').value&flete=document.getElementById('flete').value&instalacion=document.getElementById('instalacion').value&venta=document.getElementById('venta').value&total=document.get
ElementById('total').value">Realizar</a>

In insertcot.php I print show GET:

<?php 
echo "<pre>"; 
print_r($_GET); 
echo "</pre>";
?>

And i see it

  Array
    (
        [pais] => document.getElementById('pais').value
        [proyecto] => document.getElementById('proyecto').value
        [notas] => document.getElementById('notas').value
        [formapago] => document.getElementById('formapago').value
        [fechaentrega] => document.getElementById('fechaentrega').value
        [flete] => document.getElementById('flete').value
        [instalacion] => document.getElementById('instalacion').value
        [venta] => document.getElementById('venta').value
        [total] => document.getElementById('total').value
    )

As I can see, I'm not getting the values...

How could I do to get them

Upvotes: 0

Views: 1019

Answers (1)

Jonathan M
Jonathan M

Reputation: 17441

Try this. It formats the href just before submitting the HTTP request

<a class="btn btn-warning btn-sm" href="" onclick="this.href='insertcot.php?pais=' + document.getElementById('pais').value + '&proyecto=' + document.getElementById('proyecto').value + '&notas=' + document.getElementById('notas').value + '&formapago=' + document.getElementById('formapago').value + '&fechaentrega=' + document.getElementById('fechaentrega').value + '&flete=' + document.getElementById('flete').value + '&instalacion=' + document.getElementById('instalacion').value + '&venta=' + document.getElementById('venta').value + '&total=' + document.getElementById('total').value; return true">Realizar</a>

Upvotes: 1

Related Questions