Kreso wrote on 16 jun 2004 in comp.lang.javascript
:
First of all I'm not a javascript programmer!
Second I repeat everything i said in my last post
Third if you don't know the solution or PLEASE do not reply to this
post
This code when saved as an *.asp file should show a link which, when
pressed, shows a dialog which should redirect the page to itself
including some data in the url
the only way i got the page to reload (with the data included in the
url) is to put document.write("") (now commented) before the
location.href=... (or to manually refresh the page)
BEGIN CODE
<script language="javascript">
<!--
function confirmDelete(x)
{
if (confirm("Kliknite OK za brisanje. Cancel za povratak.")==true)
{trans="test.asp?action=delete&nID="+x;
//document.write("");
window.location.href = trans; }
}
//-->
</script>
<body>
<%
'//ASP CODE
if request("action")="delete" then response.write request("action")
%>
<a href="javascript:;" onclick="confirmDelete(15)">[obriči]</a>
</body>
END CODE
change this:
onclick="confirmDelete(15);"
to:
onclick="confirmDelete(15);return false;"
Otherwise it is all a question of timing which process fires first
================================================
Furthermore you could clean up your code:
[
1 Superfluous is the testing if a boolean is true,
the result being the same as the original boolean]
2 The href="javascript
:;" will not run if javscript is not active,
and it will not run if it is
]
=================================================
<%@Language=vbscript%>
<script type="text/javascript">
function confirmDelete(x) {
if (confirm("Kliknite OK za brisanje. Cancel za povratak."))
{
window.location.href = "test.asp?action=delete&nID="+x;
}
}
</script>
<body>
Action:
<% = response.write request("action") %>
<br>
ID:
<% = response.write request("ID") %>
<br>
<a href="#"
onclick="confirmDelete(15);return false">
[obriči]</a>
</body>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)