2014-11-06 58 views
1

我需要刷新我的php。頁面後我onclick,但在點擊我必須發送一些值 它是否可行?如何刷新我的php頁面:onclick

這是我的代碼:

<a class="btn btn-warning btn-sm" href="" onclick="this.href='insertaCotizacion.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/*I WANNA REFRESH MY PAGE HERE*/">Realizar</a> // 

我看到it,但我不明白

回答

1

使用location.reload();重新加載頁面。

+0

凡我必須使用它?在我的onclick?我的onclick已經做了一些事情 – 2014-11-06 22:32:51

+0

把它現在做的所有事情都包裝到一個函數中,然後讓它做它現在做的事情,然後包含'location.reload()'。 接下來,只需調用該函數onclick。 'onclick =「theFunctionToCall();」'那樣。 – Vanitas 2014-11-06 22:35:14

1

,如果你需要重新加載使用參數頁面使用window.location.href

例子:

<html> 
    <head> 
    <script> 
    function reloadUrl(){ 
    var url=insertaCotizacion.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; 
    window.location.href=url; 

    } 
    </script> 
    </head> 
    <body> 
<a href="#" onclick="javascript:reloadUrl();">LINK</a> 
    </body> 
    </html>