Solved

Dynamic submit-button?

Posted on 1997-04-07
4
244 Views
Last Modified: 2012-05-04
I want to create dynamic buttons, i.e. buttons that look
like being pressed when the mouse moves over them and return
to normal (unpressed) state when the mouse moves out.
I use onMouseOver and onMouseOut.
The code looks like this:
<html>
  <head>
  <title>Dynamic Buttons - Test</title>
  <script language="JavaScript">
  <!--
  ima1 = new Image();
  ima1.src = "button.gif";   /* normal button */
  hima1 = new Image();
  hima1.src = "button_b.gif";  /* pressed button */

  function ImageOver(Index,NewIma)
  {
   window.document.images[Index].src = NewIma.src;
  }

   //-->
   </script>
   </head>
  <body>
...
  <a href="anywhere.htm" onMouseOver="ImageOver(1,hima1)" onMouseOut="ImageOver(1,ima1)">
  <img src="button.gif" border="0"></a>
...

This works fine if the buttons are just links to other
HTML-pages.
But I want to create a dynamic submit-button.
I tried something like this:

<form>
...
<input type="image" src="button.gif"
    onMouseOver="ImageOver(1,hima1)" onMouseOut="ImageOver(1,ima1)">
</form> ...

But it doesn't work.
Does anybody know what I can do to get dynamic submit
buttons?
0
Comment
Question by:steffi
  • 3
4 Comments
 
LVL 1

Accepted Solution

by:
moorep earned 80 total points
Comment Utility
You are right. You cannot make them dynamic in a form.
You would create the images as normal <A HREF...>
with the submit button doing this:
<A HREF="javascript:form_submit()" onMouseover.... onMouseout...>
This will work. Same for the reset button too.
function form_submit()      {
      document.MyForm.submit();
// end of function
}

function form_clear() {
          // This will only work for NN 3.x and above
            document.MyForm.reset();
      }
Now i also noticed a bug in NN3.x in that if you do a "go back" to the form, the name of the form, in this case MyForm, will be lost. You should replace it with document.forms[0].submit();
where forms[0] represents the first form declared on the page.
0
 
LVL 1

Expert Comment

by:moorep
Comment Utility
I know a way to create a dynamic submit button so it is possible, but unfortunately I can't answer your question while you are evaluating another.
0
 
LVL 1

Expert Comment

by:jjung
Comment Utility
there are no mouseover mouseout events on form inputs, buttons or otherwise. This is the question she has asked and i have answered it correctly.
I can create dynamic buttons til the cows come home too.
0
 
LVL 1

Expert Comment

by:moorep
Comment Utility
Note that submit() will not work with forms that have:
ACTION=mailto:johndoe@domain.com
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now