PDA

Click to See Complete Forum and Search --> : Validate a URL


Gin_bee
Feb 12th, 2001, 11:28 PM
Hey there

have a small problem with passing a Url, its works fine at the minute but i need to validate that the remove function that the URL will carry out is what the user actually intends to do, something like a VB yes/No messgae box.

At the min my a tag is:
<a href="Remove.asp?Remove=<%=rsUser.fields("sUser")%> onClick="Remove()">DELETE</a>

The Java Script I'm attempting to run is:
Function Remove()
{var OK = window.confirm("You are about to delete this record. Click OK to delete this record. Click Cancel to stop.");
if (!OK) {
return false;
}
document.form1.submit();
}



Is this possible? Does anyone have any better ideas??
any help greatly appreciated.

Psyrus
Feb 12th, 2001, 11:51 PM
Try this:

<a HREF = "javascript:void Remove();">DELETE</a>


In your javascript code you can then do the redirect if yes was selected.

window.location = "Remove.asp?Remove=<%=rsUser.fields("sUser")%> "

I'm not totally sure how the server side code will react but it's worth a shot.

Why are you using a remove.asp page and submitting a form? What's the ACTION of the form set to? If you have it set to the remove.asp page then you do not need to redirect using the location property. The form submit will take care of that. ACTION = "Remove.asp?Remove=<%=rsUser.fields("sUser")%> "

Gin_bee
Feb 13th, 2001, 12:32 AM
Thanx for the help, All I want to be able to do is bring up a Yes/Cancel box and for some reason cant. I can get alerts to fire on clicking the Delete URl but have never used Java script before and am struggling with getting something more fancy than an alert!!!

The action of the form is set to nothing for various reasons and the remove.asp is acting as a validation area. Its being accessed by a number of forms.


Can anyone help with getting a YES/Cancel box?

Psyrus
Feb 13th, 2001, 12:48 AM
Sorry,

Misunderstood you a bit.

What problems are you having with window.confirm()?

Kagey
Feb 13th, 2001, 02:24 PM
This is something like i use. this is the function, and the thing that is to be removed is passed to it:

function box(VARIABLE)
{
if (confirm("Are you sure you want to remove "+VARIABLE+" from the database?\n\nClick OK to remove."))
{
window.location='http://www.whatever.com/remove.asp?remove=' + VARIABLE;
}
else
{
alert('Deletion aborted');
}

}

then i use this code for the hyperlink to make the function work:

<a href="javascript:box('<%=rsUser.fields("sUser")%>');"><%=rsUser.fields("sUser")%></a>

try something like that

let me know how it goes, eh.

Gin_bee
Feb 13th, 2001, 06:13 PM
just to say thanks for the help Psyrus and Kagey. I got the link to work this morning. Cant get the window.confirm to work so used the the code you suggested kagey :)

I appreciate the time.

Kagey
Feb 13th, 2001, 07:31 PM
no prob man. anytime.