Re: Possible timing problem in onclick
anonymous_at_discussions.microsoft.com
Date: 06/24/04
- Next message: anonymous_at_discussions.microsoft.com: "Re: Possible timing problem in onclick"
- Previous message: anonymous_at_discussions.microsoft.com: "Re: Possible timing problem in onclick"
- In reply to: Lisa Wollin \(Microsoft\): "Re: Possible timing problem in onclick"
- Next in thread: anonymous_at_discussions.microsoft.com: "Re: Possible timing problem in onclick"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 23 Jun 2004 18:39:59 -0700
Hi Lisa,
Thanks a lot. I think the problem was the "multiple"
tag which was left over from a previous incarnation of
the program (silly me). I also appreciate your
suggestion to use "selected Index" instead of the loop,
which makes for a much more elegant program.
>-----Original Message-----
>Hi, Gerry,
>
>On a quick glance through, in the sub you are
using "formNx" as the form
>name, but in the opening Form tag, the name attribute is
set to "Nx". Try
>changing this so that the script reads
>
> For i = 0 To Nx.selNx.Length - 1
> If Nx.selNx.Options(i).Selected _
> = True Then ix = i
> Next
> navigate("QSelect.asp?HP=2&NMix=" & ix)
>
>However, there may also be another problem. In the
Select tag you include
>the multiple attribute, which allows users to select
more than one item.
>However, when the For loop runs, only the last selected
item would end up
>becoming the value of ix. This may be fine, but just in
case, you may want
>to remove the multiple from the select tag. Also, you
can probably forgo
>the For loop and use the selectedIndex property, which
would return an
>integer of the selected item, assuming, of course, if
only one item was
>selected. In this case, you could safely replace the
For loop with the
>following code:
>
>ix = Nx.selNx.selectedIndex
>
>--
>Lisa Wollin
>Programmer Writer
>Microsoft Corporation
>
>This posting is provided "AS IS" with no warranties, and
confers no rights.
>Use of included code samples are subject to the terms
specified at
>http://www.microsoft.com/info/cpyright.htm.
><anonymous@discussions.microsoft.com> wrote in message
>news:20aa001c45979$40fa5900$a501280a@phx.gbl...
>> I have a little vbScript that is invoked by onclick in
>> one of the option lines of a select structure. With
the
>> msgbox in the script, it works fine and returns the
index
>> of the option clicked. With msgbox deleted (or
commented
>> out), it always returns -1.
>>
>> Any suggestions?
>>
>> Gerry Metze
>>
>>
>>
>> <script language="vbscript">
>> Sub selNm
>> ix = -1
>>
>> msgbox "in selNm"
>>
>> For i = 0 To formNx.selNx.Length - 1
>> If formNx.selNx.Options(i).Selected _
>> = True Then ix = i
>> Next
>> navigate("QSelect.asp?HP=2&NMix=" & ix)
>> End Sub
>> .......
>> <body>
>> <form name="Nx">
>> <fieldset>
>> <select align="left" multiple size="15"
name="selNx"
>> onclick="selNm">
>> <% For i = 1 To UBound(VV)
>> Response.Write "<option
>> onclick=""selNm2"">" & VV(i) & "</option><br>"
>> Next %>
>> </select>
>> </fieldset>
>> </form>
>
>
>.
>
- Next message: anonymous_at_discussions.microsoft.com: "Re: Possible timing problem in onclick"
- Previous message: anonymous_at_discussions.microsoft.com: "Re: Possible timing problem in onclick"
- In reply to: Lisa Wollin \(Microsoft\): "Re: Possible timing problem in onclick"
- Next in thread: anonymous_at_discussions.microsoft.com: "Re: Possible timing problem in onclick"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|