Results 1 to 7 of 7

Thread: Validate a URL

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    39
    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.

  2. #2
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    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")%> "
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    39
    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?

  4. #4
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    Sorry,

    Misunderstood you a bit.

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

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  5. #5
    Hyperactive Member Kagey's Avatar
    Join Date
    Sep 2000
    Location
    The Wilderness of New Brunswick
    Posts
    294
    This is something like i use. this is the function, and the thing that is to be removed is passed to it:
    Code:
    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:
    Code:
    <a href="javascript:box('<%=rsUser.fields("sUser")%>');"><%=rsUser.fields("sUser")%></a>
    try something like that

    let me know how it goes, eh.

  6. #6

    Thread Starter
    Member
    Join Date
    Jun 2000
    Posts
    39

    Thank You...

    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.

  7. #7
    Hyperactive Member Kagey's Avatar
    Join Date
    Sep 2000
    Location
    The Wilderness of New Brunswick
    Posts
    294
    no prob man. anytime.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width