Do forms effect the way that elements are referenced in VB script?

The following piece of code seems to work OK:-

<SCRIPT language=VBScript>
Sub NoFormDown()
imgNoForm.src = "Images/UpdateDown.gif"
paraTest.innerText = Now()
End Sub
Sub NoFormUp()
imgNoForm.src = "Images/Update.gif"
paraTest.innerText = Now()
End Sub
</SCRIPT>
<P>
<INPUT type=image src="Images/Update.gif" border=0 name="Jim"
OnMouseDown='NoFormDown()' OnMouseUp='NoFormUp()' ID=imgNoForm>
</P>

However, none of the 3 attempts to reference the <INPUT> element, seem to
work in the following piece of code

<SCRIPT language=VBScript>
Sub WithFormDown()
frmTest.elements("imgWithForm").src = "Images/UpdateDown.gif"
frmTest.imgWithForm.src = "Images/UpdateDown.gif"
imgWithForm.src = "Images/UpdateDown.gif"
paraTest.innerText = Now()
End Sub
Sub WithFormUp()
imgWithForm.src = "Images/Update.gif"
paraTest.innerText = Now()
End Sub
</SCRIPT>
<P>
<FORM action="Example.htm" method=get ID=frmTest>
<INPUT type=image src="Images/Update.gif" border=0 name="Fred"
OnMouseDown='WithFormDown()' OnMouseUp='WithFormUp()' ID=imgWithForm>
</FORM>
</P>

The only change is the <INPUT> element is now wrapped inside the <FORM>
element. How do you reference elements that are in forms?

Thanks for any help given.
--
Steve Walton

Re: Do forms effect the way that elements are referenced in VB script? by Han

Han
Sun Dec 07 08:39:21 CST 2003

Yes, sometimes experience is truth.

"Steven Walton" <NoSpam@NoSpam.com> wrote in message
news:OMe7cknuDHA.3536@tk2msftngp13.phx.gbl...
> Do forms effect the way that elements are referenced in VB script?
>
> The following piece of code seems to work OK:-
>
> <SCRIPT language=VBScript>
> Sub NoFormDown()
> imgNoForm.src = "Images/UpdateDown.gif"
> paraTest.innerText = Now()
> End Sub
> Sub NoFormUp()
> imgNoForm.src = "Images/Update.gif"
> paraTest.innerText = Now()
> End Sub
> </SCRIPT>
> <P>
> <INPUT type=image src="Images/Update.gif" border=0 name="Jim"
> OnMouseDown='NoFormDown()' OnMouseUp='NoFormUp()' ID=imgNoForm>
> </P>
>
> However, none of the 3 attempts to reference the <INPUT> element, seem to
> work in the following piece of code
>
> <SCRIPT language=VBScript>
> Sub WithFormDown()
> frmTest.elements("imgWithForm").src = "Images/UpdateDown.gif"
> frmTest.imgWithForm.src = "Images/UpdateDown.gif"
> imgWithForm.src = "Images/UpdateDown.gif"
> paraTest.innerText = Now()
> End Sub
> Sub WithFormUp()
> imgWithForm.src = "Images/Update.gif"
> paraTest.innerText = Now()
> End Sub
> </SCRIPT>
> <P>
> <FORM action="Example.htm" method=get ID=frmTest>
> <INPUT type=image src="Images/Update.gif" border=0 name="Fred"
> OnMouseDown='WithFormDown()' OnMouseUp='WithFormUp()' ID=imgWithForm>
> </FORM>
> </P>
>
> The only change is the <INPUT> element is now wrapped inside the <FORM>
> element. How do you reference elements that are in forms?
>
> Thanks for any help given.
> --
> Steve Walton
>
>



Re: Do forms effect the way that elements are referenced in VB script? by Bob

Bob
Sun Dec 07 09:05:40 CST 2003

Steven Walton wrote:
> Do forms effect the way that elements are referenced in VB script?
>
> The following piece of code seems to work OK:-
>
> <SCRIPT language=VBScript>
> Sub NoFormDown()
> imgNoForm.src = "Images/UpdateDown.gif"
> paraTest.innerText = Now()
> End Sub
> Sub NoFormUp()
> imgNoForm.src = "Images/Update.gif"
> paraTest.innerText = Now()
> End Sub
> </SCRIPT>
> <P>
> <INPUT type=image src="Images/Update.gif" border=0 name="Jim"
> OnMouseDown='NoFormDown()' OnMouseUp='NoFormUp()' ID=imgNoForm>
> </P>
>
> However, none of the 3 attempts to reference the <INPUT> element,
> seem to work in the following piece of code
>
> <SCRIPT language=VBScript>
> Sub WithFormDown()
> frmTest.elements("imgWithForm").src = "Images/UpdateDown.gif"
> frmTest.imgWithForm.src = "Images/UpdateDown.gif"
> imgWithForm.src = "Images/UpdateDown.gif"
> paraTest.innerText = Now()
> End Sub
> Sub WithFormUp()
> imgWithForm.src = "Images/Update.gif"
> paraTest.innerText = Now()
> End Sub
> </SCRIPT>
> <P>
> <FORM action="Example.htm" method=get ID=frmTest>
> <INPUT type=image src="Images/Update.gif" border=0 name="Fred"
> OnMouseDown='WithFormDown()' OnMouseUp='WithFormUp()' ID=imgWithForm>
> </FORM>
> </P>
>
> The only change is the <INPUT> element is now wrapped inside the
> <FORM> element. How do you reference elements that are in forms?
>
> Thanks for any help given.

This should work:
frmTest.imgWithForm.src = "Images/UpdateDown.gif"

The fact that you say it doesn't leads me to believe that something else is
wrong.

I copied your html into a test page and got the same error I think you were
getting. I changed the INPUT to an IMG and it works fine. Why do you want
the image to change if you are causing the form to be immediately submitted
when clicked?

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"



Re: Do forms effect the way that elements are referenced in VB script? by Steven

Steven
Mon Dec 08 04:03:44 CST 2003

I would like to display the image of a pressed button when the mouse button
is pressed. The form is submitted when the mouse button is released.

Thanks, I am glad it's not just me.
--
Steve Walton


"Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
news:%23WqoTONvDHA.3140@TK2MSFTNGP11.phx.gbl...
>
> This should work:
> frmTest.imgWithForm.src = "Images/UpdateDown.gif"
>
> The fact that you say it doesn't leads me to believe that something else
is
> wrong.
>
> I copied your html into a test page and got the same error I think you
were
> getting. I changed the INPUT to an IMG and it works fine. Why do you want
> the image to change if you are causing the form to be immediately
submitted
> when clicked?
>
> Bob Barrows
>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>
>