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: 10417
  • Last Modified:

Enable & Disable A HyperLink

Okay, i have a table in which i want to display a DISABLED shortlist hyperlink by default for each looped row. The shortlist hyperlink can only be enabled when the user clicks on the viewdetails hyperlink. How can this be achieved ? and is there a nice way to show different images for disabled and enabled states. I know javascript will have to be used in some form.

<cfoutput query="Get_Query" startrow="#URL.sl_StartRow#" maxrows="#sl_RowsPerPage#">
<tr>
   <td><a href="/viewdetails.cfm">#Get_Query.PersonName<td>
   <td><a href="/shortlist.cfm"><img src="/save.gif"></a></td>
</tr>
</cfoutput>

Cheers

JT
0
jturkington
Asked:
jturkington
3 Solutions
 
Ike23Commented:
I'm not sure what you mean by a "disabled shortlist hyperlink" but it sounds like you want to make the user click the first link in order to see the second link correct?   This sounds like a good candidate for using Javascript and CSS with a id element.

Basically you have content on your page that you put inside of <div> tags with an id="" value (you could populate this dynamically from your <cfoutput>).  Then the links will call a javascript function that will change the ID value and display the content in whichever <div> tag is chosen.

Here's a few examples:

http://support.internetconnection.net/CODE_LIBRARY/Javascript_Show_Hide.shtml

http://www.dyn-web.com/dhtml/show-hide/

http://www.netlobo.com/div_hiding.html

Cheers!

Ike
0
 
pmascariCommented:
Javascript is definitely needed.

Allow me to introduce you to my little friend: CFAjax.  

http://www.indiankey.com/cfajax/
0
 
jturkingtonAuthor Commented:
What about using buttons and enabling & disabling them, the problem is i have to uniquely name each button for each currently looped row.

<cfoutput query="Get_Query" startrow="#URL.sl_StartRow#" maxrows="#sl_RowsPerPage#">

<tr>
   <td>
      <!--- Hyperlink to enable button --->
      <a href="/viewdetails.cfm" target="dsp_contact" onclick="openPopup(this.href, this.target,800,600);
      document.thispage.button#Get_Query.currentrow#.disabled=false;">">#Get_Query.PersonName#</a>
   </td>
   <td>
      <!---Then the button for each looped row --->
      <input type="button" value="Shortlist" name="button#Get_Query.currentrow#" onclick="return!openPopup
      ('/shortlist.cfm', '_parent',1024,768)" disabled="true">
   </td>
<tr>
</cfoutput>

what do you think  ?

JT
0
 
JeffHowdenCommented:
CFAJAX or AJAX of any variety is *definitely* not needed for something super-simple like this.  See if the following really basic example gets you headed in the right direction:

<script type="text/javascript">
  function enableLink(id)
  {
    if(document.getElementById)
    {
      oLink = document.getElementById(id);
      if(oLink)
        oLink.disabled = false;
    }
    return false;
  }
</script>

<cfoutput query="Get_Query" startrow="#URL.sl_StartRow#" maxrows="#sl_RowsPerPage#">
<tr>
   <td><a href="/viewdetails.cfm" onclick="return enableLink('link-#Get_Query.id#')">#Get_Query.PersonName#</a><td>
   <td><a href="/shortlist.cfm" id="link-#Get_Query.id#" disabled="disabled" onclick="return !this.disabled"><img src="/save.gif"></a></td>
</tr>
</cfoutput>
0
 
Ike23Commented:
I agree with Jeff that Ajax is probalby overkill on this one.  You could still use buttons but it would be better to just call a javascript funtion from the button that would enable it similar to what Jeff provided above.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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