2014-11-06 99 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>