Click to See Complete Forum and Search --> : Image Linking


karlmcauley
08-05-2003, 05:14 AM
Dont know if this is possible, but here goes;

I have a list of reports stored in an oracle table and displayed via an sql query on an asp page. Each report has a report ID e.g. 1, 2, 3, 4, 5 etc etc. beside each report ID is an image which says run report.

If a user selects this image then i first want to test for something before running the report. Depending on if this test returns true or false i want to direct the user to a different screen?? Confused?

Code:

<%

dim theUrl

If rsTemp("repcriteria") = "Y" then
theUrl="sub_menu.asp"
else
theUrl="run_reports.asp"
end if%>

<a href=<%="theUrl"%>></a><img src="../images/darkplus.gif" width = "20" height="20"></a>

The link to the database is fine, but the problem is theUrl link within the image. Am i crazy or overlooking something or can this be done. If the criteria flag in the database is Y i need to open a page called sub_menu.asp else (if it is N) i need to open a page called run_reports.asp.....and this needs to be done on clicking the image!!

Would it be better to try a JScript function called through the onclick event of the image?

gil davis
08-05-2003, 08:39 AM
Am i crazy or overlooking something or can this be done.
You cannot use server-side code on the client. Your server-side code has already executed, and the client doesn't even see it. Therefore, when the user clicks the image, nothing can possibly happen, because the code is only on the server.

You will have to build some kind of array that can be sent to the client so that a script on the client can check the Y/N thing.

karlmcauley
08-05-2003, 10:27 AM
What??

The above is an excerpt from an asp script that communicates with a server and return the results to the client. The connection data has not been given to you!!
So i dont know if you have been misled or why you think the client cannot communicate with server?

<a href=<%response.write theUrl>><img src="../images/darkplus.gif" width = "20" height="20"></a>

Now works instead of what i had.

Regards

Khalid Ali
08-05-2003, 11:16 AM
2 points.

1. if you are testing the conditionin js then you are all set just submit the form if the condition returns trueother wise you will have to send the form to your asp processing page and validate condition if true display report else
redirect("tosomeotherpage.html")