Link to home
Start Free TrialLog in
Avatar of steva
steva

asked on

Disabling links

What it the best way to disable links?

I have a download link that I would like to gray  out and make it inactive until the user submits a contact form.  I can imagine writing a lot of JavaScript to implement this, but I'm wondering if there's a simply way already out there.

Thanks for any ideas.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
what is the action after the contact form is submitted?

are you using any server side programming language for your portal? if yes then I suggest you can disable the link by server side scripting, instead of javascript, which is a client side scripting.
Avatar of steva
steva

ASKER

ryancys:

The action after the form is submitted is the visitor selects the enabled link  to download a file. I am using aspx on the server and so could do something from the server, I suppose, but why involve a trip to the server and back when it can all be done in the viewer's browser?

leakim:

Yep.  That'll work!  Thanks.

By the way, I notice that you set the status variable to false in  the header section by
just placing "var status=false;" up there between script tags, without executing
status=false; in an onload function. There's no question that it works here, but I've gotten
into trouble doing that and I'm just wondering when it's safe. The first code below, for example, doesn't
work while the second code does. The flvP and flaP variables being set are used farther down in my markup to access a swf object and they don't get set correctly for the first case below.


       /*    Doesn't work   */

<script type="text/javascript">
   
    var isIE = navigator.appName.indexOf("Microsoft") != -1;
    var flvP = (isIE) ? window['flvPlayer'] : document['flvPlayer'];
    var flaP = (isIE) ? window['flaPlayer'] : document['flaPlayer'];
 
  function tryWelcome() { /* called by body onload */
 
      var welcomed = false;
                     *
                     *
                     *

              /* Works  */

<script type="text/javascript">

    var flvP;       // Flash video player.
    var flaP;        // Flash animation player

  function tryWelcome() {  /* called by body onload */
    var isIE = navigator.appName.indexOf("Microsoft") != -1;
    flvP = (isIE) ? window['flvPlayer'] : document['flvPlayer'];
    flaP = (isIE) ? window['flaPlayer'] : document['flaPlayer'];
 
      var welcomed = false;
                      *
                      *
                      *


Thanks for the help.

>>but why involve a trip to the server and back when it can all be done in the viewer's browser?

It's depends on your requirement, one of the reaons why doing it on server side is security reason.

another reason, no need to worry about whether javascript is enabled on browser or the syntax of javascript, as what you facing above.
If it don't work it's because you work with or on null objects. The object doen't exists, not created, or are not again reacheable.
Avatar of steva

ASKER

Thanks.
Thanks for the points!