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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript Prompt 1

Status
Not open for further replies.

jmurrayhead

Programmer
Feb 13, 2004
47
US
Hello,

I have a page that displays records from a database. Two columns in the table that displays the records are an edit and delete links that I have. These are referring URLs. On the delete button I want a confirmation box to display to prevent accidental deletion. How can I do this and how do I use the gif image to click on instead of the form button?

Thanks
 
You will need to use a client side script to have the message box pop-up. Second to get an image to submit instead of a button do the following:
--------------------------------------------
<SCRIPT LANGUAGE=vbscript>
<!--
sub showbox()
dim iAnswer

iAnswer = msgbox( "Delete?",vbyesno,"Verify")

if iAnswer = 6 then
'Yes was clicked
'Process code needed
else
'No was clicked
'Process code needed
end if

end sub
//-->
</SCRIPT>

<input TYPE="image" SRC=" ALT="mouseovertext" onclick=showbox id=image1 name=image1>

---------------------------------

Place the code you need to process where indicated. Let me know if you need anything else.

Cassidy

--------------------------------------
Cassidy: Proprietor of the ID 10 T tool. Orders yours today!!!
 
Okay so if iAnswer = 6 then I could use a response.redirect to my delsql.asp correct? As of right now, for each record, this is what I have for the delete:

Code:
response.write("<a href=""management/delsql.asp?KNum=" & KNum & "&CLID=" & ClassID & """><img src='/images/del.jpg' border='0' alt='Delete'></a>")

So if I put

if iAnswer = 6 then
reponse.redirect ("management/delsql.asp?KNum=" & KNum & "&CLID=" & ClassID & """)

would that take the value from the record clicked on and take those values to the delete sql?
 
Actually you will use the client side script to navigate to the ASP page.

window.navigate "-------------------------------------
So it will look like this

<SCRIPT LANGUAGE=vbscript>
<!--
sub showbox()
dim iAnswer

iAnswer = msgbox( "Delete?",vbyesno,"Verify")

if iAnswer = 6 then
'Yes was clicked
'Process code needed
window.navigate " URL"
else
'No was clicked
'Process code needed
end if

end sub
//-->
</SCRIPT>
------------------------------

From here you can have anything you want on the ASP page.

Let me know if you need anything else.


--------------------------------------
Cassidy: Proprietor of the ID 10 T tool. Orders yours today!!!
 
You will probably have to pass the information to the routine. I just took a second look at what you had wrote.

so your sub will look something like this:

<SCRIPT LANGUAGE=vbscript>
<!--
sub showbox(sURL)
dim iAnswer

iAnswer = msgbox( "Delete?",vbyesno,"Verify")

if iAnswer = 6 then
'Yes was clicked
'Process code needed
window.navigate sURL
else
'No was clicked
'Process code needed
end if

end sub
//-->
</SCRIPT>

<input TYPE="image" SRC=" ALT="mouseovertext" onclick=showbox("URL to navigate to with server script") id=image1 name=image1>

--------------
Sorry about the prior post. I didn't read it carefully enough.

Let me know if you have anymore questions.


--------------------------------------
Cassidy: Proprietor of the ID 10 T tool. Orders yours today!!!
 
Here is how I would do what your trying to do:

<SCRIPT LANGUAGE=vbscript>
<!--
sub showbox(sURL)
dim iAnswer

iAnswer = msgbox( "Delete?",vbyesno,"Verify")

if iAnswer = 6 then
'Yes was clicked
'Process code needed
window.navigate sURL
else
'No was clicked
'Process code needed
end if

end sub
//-->
</SCRIPT>

<%
'Server side script

dim s

s = " & KNum & "&CLID=" & ClassID & "

%>
<input TYPE="image" SRC=" ALT="mouseovertext" onclick=showbox("<%Response.write s%>") id=image1 name=image1>


Let me know if you need more.



--------------------------------------
Cassidy: Proprietor of the ID 10 T tool. Orders yours today!!!
 
When I click Delete, nothing happens. Here's what I have:

Code:
<SCRIPT LANGUAGE=vbscript>
<!--
sub delver(sURL)
    dim iAnswer
    
    iAnswer = msgbox("Are you sure you want to delete this record?",vbyesno,"Verify")
    
    if iAnswer = 6 then
        'Yes was clicked
        'Process code needed
        window.navigate sURL
    else
        'No was clicked
        'Process code needed
    end if
    
end sub
//-->

Defining variable
Code:
Dim s
s="[URL unfurl="true"]http://mysite.com/assignments/management/delsql.asp?KNum="[/URL] & KNum & "&CLID=" & ClassID & ""

and in the table
Code:
<input TYPE="image" SRC="/images/del.jpg" ALT="Delete" onclick="delver("<%response.write s%>")" id="DelImg" name="DelImg">

Thanks for your help
 
I think you are passing to many quotes to the function. Try this

Code:
Dim s
s="[URL unfurl="true"]http://mysite.com/assignments/management/delsql.asp?KNum="[/URL] & KNum & "&CLID=" & ClassID

Also in your call from the input button you do not have to place quotes around the sub routine call. do it like this:

Code:
<input TYPE="image" SRC="/images/del.jpg" ALT="Delete" onclick=delver("<%response.write s%>") id="DelImg" name="DelImg">

Let me know if that works.



--------------------------------------
Cassidy: Proprietor of the ID 10 T tool. Orders yours today!!!
 
Yup, too many quotes! Thanks for all of your help! Works perfectly!!
 
No problem. Glad to help.

Cassidy

--------------------------------------
Cassidy: Proprietor of the ID 10 T tool. Orders yours today!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top