Solved

Modify Hover Button to Lock After CLICK?

Posted on 2004-10-19
3
1,216 Views
Last Modified: 2012-08-14
Can u help? With some great help from EE experts I have this wonderful (and working) script below that displays a hover button with three states:

- hover on - img : "button_on_reg_subscribe.jpg"
- hover off - img : "button_off_reg_subscribe.jpg"
- clicked - img : "button_click_reg_subscribe.jpg"

Again - this works well - but I need to modify!.  The button is used for submitting credit card payments to some code that processes the payment and either authorizes or rejects etc.  BUT on testing this form I realize I need to ensure the user does not CLICK the button more than ONCE!

SO ... can someone please help me with this modification:

WHEN THE USER CLICKS the above button ... LOCK the button (so it cannot be clicked again) and LOCK the image (leave the image) as "button_click_reg_subscribe.jpg" - EVEN when the user's mouse is no longer ON the image?

Does this make sense?

THIS IS THE CURRENT CODE:


<script>
function VMaxOver2(link,id,overIm) {
if(document.images) {
 im            = document.images[id];
 im.outIm      = new Image();
 im.overIm     = new Image();
 im.outIm.src  = document.images[id].src;
 im.overIm.src = overIm;
 im.src        = im.overIm.src;
 link.onmouseout  = new Function("var im=document."+id+"; im.src=im.outIm.src;");
 link.onmouseover = new Function("var im=document."+id+"; im.src=im.overIm.src;");
 }
}
</script>


<a onClick="VMaxOver2(this,'button_reg_subscribe','./newopex_graphics/button_click_reg_subscribe.gif');document.forms['process_payment'].submit();" onMouseOver="VMaxOver2(this,'button_reg_subscribe','./newopex_graphics/button_on_reg_subscribe.jpg')"><IMG NAME="button_reg_subscribe" SRC="./newopex_graphics/button_off_reg_subscribe.jpg" border=0 width="105" height="34"></a>



Thanks for your help!
Richard
0
Comment
Question by:rcbuchanan
3 Comments
 
LVL 5

Accepted Solution

by:
darksinclair earned 500 total points
ID: 12347663
<a onClick="this.disabled='true';VMaxOver2(this,'button_reg_subscribe','./newopex_graphics/button_click_reg_subscribe.gif');document.forms['process_payment'].submit();" onMouseOver="VMaxOver2(this,'button_reg_subscribe','./newopex_graphics/button_on_reg_subscribe.jpg')"><IMG NAME="button_reg_subscribe" SRC="./newopex_graphics/button_off_reg_subscribe.jpg" border=0 width="105" height="34"></a>


Try the above .. it will disable the button when you click on it and then go through your VMaxOVer2 function.

Cheers,
0
 
LVL 18

Expert Comment

by:arantius
ID: 12347836
Online example: http://www.arantius.com/ee/Q_21173866.html
Remove the alert("Submit") and uncomment the line before, make it actually submit your form.

<html>
<head>
<script type="text/javascript">
var clicked=false;
function setImage(img, state) {
      if (clicked) return;
      switch (state) {
            case "on": img.src="cloud2.png"; break;
            case "off": img.src="cloud1.png"; break;
            case "click": img.src="cloud3.png"; break;
            case "dis":
                  img.src="cloud-dis.png";
                  clicked=true;
                  //document.forms.xxxx.submit();
                  alert("submit");
                  break;
      }      
}
</script>
</head>
<body>

<img src="cloud1.png"
      border="0"
      onmouseover="javascript:setImage(this, 'on');"
      onmouseout="javascript:setImage(this, 'off');"
      onmousedown="javascript:setImage(this, 'click');"
      onmouseup="javascript:setImage(this, 'dis');"
>

</body>
</html>
0
 

Author Comment

by:rcbuchanan
ID: 12351916
thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

This article discusses how to create an extensible mechanism for linked drop downs.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

839 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