?
Solved

Swap Image on click  & renaming value of displayed column

Posted on 2003-03-03
6
Medium Priority
?
2,977 Views
Last Modified: 2007-12-19
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
Comment
Question by:kumanyoko
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 5

Expert Comment

by:elvistheprince
ID: 8078903
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
 

Expert Comment

by:mpalmati
ID: 8173858
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
 

Author Comment

by:kumanyoko
ID: 8174680
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
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

 

Expert Comment

by:mpalmati
ID: 8175211
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
 

Accepted Solution

by:
Corrupticus earned 320 total points
ID: 8782740
Try
<%
If ( (request.querystring("sortby") = "company" and request.querystring("orderby") = "ASC") then
Response.Write "<img src='images/companyOnAsc.gif'>"
%>
0
 

Author Comment

by:kumanyoko
ID: 8782825
just what I was looking for - thanks!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question