Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password alert/prompt box to confirm deletion 1

Status
Not open for further replies.
Nov 2, 2005
9
0
0
US
Hello Again,

I'm tweaking this little page i have that deletes records from the DB. The bulk of the page is written in ASP, and as it stands now the user (who's already supplied their credentials) has the option to delete certain displayed records from the database.



Code:
<script type="text/javascript" language="JavaScript">
<!--
function valideer(theForm) {
var checkSelected = false;
for (i = 0;  i < theForm.Delete.length;  i++)
{
if (theForm.Delete[i].checked)
checkSelected = true;
}
if (!checkSelected)
{
alert("Nothing is selected, arse.");
return (false);
}
else
return confirm('Click OK to Permanently remove \n\ record(s) from the database!');
}
//-->
</script>

<form name="DeleteChecked" onsubmit="return valideer(this);" method="post" action="dodelete.asp">

<input type="checkbox" name="Delete" value="<%=(listRes.Fields.Item("id").Value)%>">

<%
    End If
    Counter = Counter + 1
    listRes.MoveNext
    Loop
	DateModList.Close
    Response.Write("<tr><p><td colspan=""10"" align=""right"">&nbsp;</td></tr>")
    Response.Write("<tr><p><td colspan=""10"" align=""right"">")
    Response.Write("<input type=""submit"" value=""delete""></center></td></tr></table>")

the recordset displays here!


</form>

Instead of the confirm alert:

return confirm('Click OK to Permanently remove \n\ record(s) from the database!');

I would like to use a simple password prompt or input prompt. This would require the user to actually do something besides just hit enter or click 'OK'...so that a conscious effort must be made to delete the records.

I'm not concerned with the security of the whole thing...I just want a little extra thought to go into deleting the record...so the old "I dunno.. It just asked me something and I clicked 'OK'" excuse can be negated.

I understand that I am asking alot of end users to actually think...but hope is what keeps me going.

This seems plausible and would be a simple solution without slaughtering the working ASP code.

Thanks again for all your help.


-mk
 
why not something like:

Code:
var p = prompt("enter password");
if ( !p || p != "password" ) {
    return false;
}

*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
beware of active imagination: [URL unfurl="true"]http://www.coryarthus.com/[/url]

BillyRayPreachersSonIsTheLeetestHax0rDude
[banghead]
 
so it would become:
Code:
}
else
var p = prompt("enter password");
if ( !p || p != "password" ) {
    return false;
}

?
 
else [red]{[/red]
var p = prompt("enter password");
if ( !p || p != "password" ) {
return false;
}
[red]}[/red]

always try to indent your code.

i haven't tested it, but the logic is as follows:

get the value of a user-entered value. if the user x's out of the box, p will not have a value. that is why i say !p

so,

if p does not exist or p is not equal to "password", return false.

*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
beware of active imagination: [URL unfurl="true"]http://www.coryarthus.com/[/url]

BillyRayPreachersSonIsTheLeetestHax0rDude
[banghead]
 
works like a champ!

thanks ...It's kind of embarassing I've obviously been sitting behind a desk too long... ahh.. alas the good ol days down in the trenches. It does buy premium liquor though... toss up~ *good booze *not having to ask questions on the javascript forum

My new years resolution is to re-familiarize myself with javascript

thanks again cLFlaVa

Is there a way to control the behaviour of the prompt box.. I seem to remember IE doesn't let you change the location of the prompt but is there a way to pretty it up a bit?

 
unfortunately not. you'd have to use a custom html page with a form to capture the password. IMO, not worth the effort.

*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
beware of active imagination: [URL unfurl="true"]http://www.coryarthus.com/[/url]

BillyRayPreachersSonIsTheLeetestHax0rDude
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top