[Javascript] accessing a form element

Günther Mittermayer g_mitter at web.de
Mon Apr 5 09:02:06 CDT 2004


Hi Matt, 

you have no Idea on how much more time you saved me! Thanks a lot!!
Your "getElementById ("theinput");" hint saved my day!!

BTW, is there any online documentation on the javascript functions? I mean something like Java's class documentation... somewhere where I could know all methods in the document class?

Tks once again.
Günther.

"[JavaScript List]" <javascript at LaTech.edu> schrieb am 05.04.04 15:37:27:
> 
> Hi there.
> 
> I'd do something like this (usual caveat applies: I haven't tested this, and
> it may be riddled with typo's, but it should give you an idea....)
> 
> <!-- Start -->
> <input type="image" id="theinput" src="/pics/image1.png">
> <script language="javascript">
> var oInput = document.getELementById ("theinput");
> var oImage1=new Image();
> var oImage2=new Image();
> var bFlag = true
> oImage1.src="/pics/image1.png";
> oImage2.src="/pics/image2.png";
> 
> // this function will do the image swapping - call it with your settimeout
> method
> function swapImages () {
>     if (bFlag) {
>         bFlag = false;
>         oInput.src = oImage1.src;
>     } else {
>         bFlag = true;
>         oInput.src = oImage2.src;
>     }
>     setTimeout ("swapImages();", 500);
> }
> 
> setTimeout ("swapImages();", 500);
> 
> </script>
> <!-- Fin -->
> 
> Hope this help
> 
> Matt
> 
> ----- Original Message ----- 
> From: "Günther Mittermayer" <g_mitter at web.de>
> To: <javascript at LaTech.edu>
> Sent: Monday, April 05, 2004 2:21 PM
> Subject: [Javascript] accessing a form element
> 
> 
> Hi all,
> 
> I'm kind of stuck here.
> I have an application that has a form, in which a image button must have its
> image swapped periodically.
> 
> My idea was to have a javascript script swapping the "src" attribute of the
> image button.  I have already lost a lot of time trying to have it working,
> but it simply doesn't. I get the following error:
> 
> Error: document.form1.image1 has no properties.
> 
> Can anyone help me finding out what's wrong?? Any help is welcome!!!!! I
> said ANY!
> 
> thanx in advance!!
> Günther.
> =======
> Here is some code:
> 
> the javascript function:
> function refresh_image()
> {
> //Refreshes the image
> document.form1.image1.src="whatever.png";
> setTimeout('refresh_image();',500);
> }
> 
> and the form looks like this:
> <form method="post" action="theaction.cgi"
> enctype="application/x-www-form-urlencoded" name="form1">
>       <input type="image" name="image1" src="../pics/the_image.png" />
> </form>
> _____________________________________________________________________
> Der WEB.DE Virenschutz schuetzt Ihr Postfach vor dem Wurm Netsky.A-P!
> Kostenfrei fuer alle FreeMail Nutzer. http://f.web.de/?mc=021157
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> --
> This email has been verified as Virus free
> Virus Protection and more available at http://www.plus.net
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript


_____________________________________________________________________
Der WEB.DE Virenschutz schuetzt Ihr Postfach vor dem Wurm Netsky.A-P!
Kostenfrei fuer alle FreeMail Nutzer. http://f.web.de/?mc=021157




More information about the Javascript mailing list