Re: Possible timing problem in onclick

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

anonymous_at_discussions.microsoft.com
Date: 06/24/04


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>
>
>
>.
>



Relevant Pages

  • Re: Possible timing problem in onclick
    ... didn't without it -- must have been the multiple tag. ... regarding "selectedIndex". ... >changing this so that the script reads ... >However, when the For loop runs, only the last selected ...
    (microsoft.public.frontpage.programming)
  • Re: Timing using Transponders
    ... >which is attached to the competator, and a mat is placed at the finish which ... up the tag via a transmitted EM field from the loop in the track. ... The loops in professional gear are embedded into the track, and don't have mats. ... Since the transponders are active transmitters, then the loop would only have to ...
    (sci.electronics.design)
  • Re: "also" to balance "else" ?
    ... in reguard to the loop test it self, it's just when you apply it to the loop as a whole, the resulting expected code flow becomes counter intuitive. ... tag = 'replace' ...
    (comp.lang.python)
  • Re: Plain text file on web server, questions please...
    ... aa.html looks like in your browser. ... but this time you close the tag. ... and use a while loop to run through them looking for something to do. ...
    (alt.os.linux)
  • Re: Possible timing problem in onclick
    ... in the sub you are using "formNx" as the form ... name, but in the opening Form tag, the name attribute is set to "Nx". ... the For loop and use the selectedIndex property, ...
    (microsoft.public.frontpage.programming)