Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2983
  • Last Modified:

Swap Image on click & renaming value of displayed column

I am building an access-based ASP/vbscript website with Dreamweaver. I have 3 columns in my database that I'd like results sorted by - company, proposal, and sponsor. The way I do this is by having the user click on an image-based tab with a url parameter that reloads the page with the corresponding sort.

As well as swapping the tabs onMouseOver, I wish to change/swap the tab clicked on by the user to select the sort, so that it is readily apparent to the user what the current sort is. I've attempted to do this with dreamweaver's onClick function (via Design -> behaviors) but my problem is that when the page reloads with the correct sorting, the clicked image reverts to its former 'unclicked' state. Is there anyway to keep track of what image has been clicked, and maintain its 'clicked' status even when the page reloads with the new sort?

Here are some code snippets:
The tabs have links as:
1) proposals.asp?sortby=company (default - without tab click)
2) proposals.asp?sortby=sponsor
3) proposals.asp?sortby=proposal

Here's the actual onClick code: (all on one line)
<a href="proposals.asp?sortby=company" onMouseOver="MM_swapImage('companyOn','','images/companyOn.gif','sponsorOff','','images/sponsorOff.gif','proposalOff','','images/proposalOff.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/companyOn.gif" name="companyOn" width="102" height="30" border="0" id="companyOn"></a>
<a href="proposals.asp?sortby=sponsor"onClick="MM_swapImage('companyOn','','images/companyOff.gif','sponsorOff','','images/sponsorOn.gif','proposalOff','','images/proposalOff.gif',1)" onMouseOver="MM_swapImage('companyOn','','images/companyOff.gif','sponsorOff','','images/sponsorOn.gif','proposalOff','','images/proposalOff.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/sponsorOff.gif" name="sponsorOff" width="102" height="30" border="0" id="sponsorOff"></a>
<a href="proposals.asp?sortby=proposal"onClick="MM_swapImage('companyOn','','images/companyOff.gif','sponsorOff','','images/sponsorOff.gif','proposalOff','','images/proposalOn.gif',1)" onMouseOver="MM_swapImage('companyOn','','images/companyOff.gif','sponsorOff','','images/sponsorOff.gif','proposalOff','','images/proposalOn.gif',1)" onMouseOut="MM_swapImgRestore()"><img src="images/proposalOff.gif" name="proposalOff" width="102" height="30" border="0" id="proposalOff"></a>

Dreamweaver's MM_swapImage fcn looks like:
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

Any Ideas?

Also, is there any way to substitute the displayed value of a database column from say 'True' to 'No'? I would for instance like to change the output of
<%=(rsProposals.Fields.Item("Key Vote?").Value)%> depending on what the value is...

Thanks.

0
kumanyoko
Asked:
kumanyoko
1 Solution
 
elvistheprinceCommented:
Second Question:
<%if rsProposals.Fields.Item("Key Vote?").Value
   then
     response.Write("No")
   else
     response.Write("Yes")
End If%>

There are smaller ways to do this of course but this allows you to see what is going on, if you have a lot of these you could also turn it into a function, so save typing/make the code look neater.

First Question answer on the way.

Stephen
0
 
mpalmatiCommented:
I would use If/Else to call your Querystring variables and write your image source html based on that.
For your image-swap code:
<a href="proposals.asp?sortby=company" onMouseOver="MM_swapImage('companyOn','','images/companyOn.gif','sponsorOff','','images/sponsorOff.gif','proposalOff','','images/proposalOff.gif',1)" onMouseOut="MM_swapImgRestore()"><% IF Request.Querystring("sortby")="company" THEN Response.Write "<img src='images/companyOn.gif' name='companyOn' width='102' height='30' border='0' id='companyOn'></a>" ELSE Response.Write "<img src='images/companyOff.gif' name='companyOff' width='102' height='30' border='0' id='companyOff'></a>" %>

You can do this for all three, it should place your "Off" images on the page by default and put your "On" images up when the qstring value matches.

For the second part it might be easier to use the Replace function...
I would write: <%Response.Write Replace (rsProposals("KeyVote?"), "True", "Yes")%> <%Response.Write Replace (rsProposals("KeyVote?"), "False", "No")%>
You can add optional vbtextcompare or vbbinarycompare parameters to the ends of those if you want to make the case insensitive or sensitive, respectively...but I don't think you'll need to if you're using an access db.  good luck.
0
 
kumanyokoAuthor Commented:
Thanks for your comments mpalmati, I overcame my hurdles a while back by using If (rsProposals.Fields.Item("Key Vote?").Value)= "False" Then Response.Write "No". For the first problem I used: <%If ( (request.querystring("sortby") = "company" and request.querystring("orderby") = "ASC")... Response.Write "<img src='images/companyOnAsc.gif'...

Had your answers come before I figured this out, the points would definitely have been yours!! - they've gone towards another question now :(
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
mpalmatiCommented:
I would use If/Else to call your Querystring variables and write your image source html based on that.
For your image-swap code:
<a href="proposals.asp?sortby=company" onMouseOver="MM_swapImage('companyOn','','images/companyOn.gif','sponsorOff','','images/sponsorOff.gif','proposalOff','','images/proposalOff.gif',1)" onMouseOut="MM_swapImgRestore()"><% IF Request.Querystring("sortby")="company" THEN Response.Write "<img src='images/companyOn.gif' name='companyOn' width='102' height='30' border='0' id='companyOn'></a>" ELSE Response.Write "<img src='images/companyOff.gif' name='companyOff' width='102' height='30' border='0' id='companyOff'></a>" %>

You can do this for all three, it should place your "Off" images on the page by default and put your "On" images up when the qstring value matches.

For the second part it might be easier to use the Replace function...
I would write: <%Response.Write Replace (rsProposals("KeyVote?"), "True", "Yes")%> <%Response.Write Replace (rsProposals("KeyVote?"), "False", "No")%>
You can add optional vbtextcompare or vbbinarycompare parameters to the ends of those if you want to make the case insensitive or sensitive, respectively...but I don't think you'll need to if you're using an access db.  good luck.
0
 
CorrupticusCommented:
Try
<%
If ( (request.querystring("sortby") = "company" and request.querystring("orderby") = "ASC") then
Response.Write "<img src='images/companyOnAsc.gif'>"
%>
0
 
kumanyokoAuthor Commented:
just what I was looking for - thanks!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now