vbscript conversion to javascript help!

Results 1 to 3 of 3

Thread: vbscript conversion to javascript help!

  1. #1
    Join Date
    Dec 1969

    Default vbscript conversion to javascript help!

    Good morning, I would like to convert the following VB code to a javascript function. Basically, it&#039;s a search function. When the user enters sth on the textInput box then the droplist will be highlighted if they match. Could you please help me convert it to a javascript function? Thanks a lot!<BR><BR>Here is the code:<BR> Sub handleChange()<BR> For i = 0 To formName.dropList.ListCount - 1<BR> If left(formName.dropList.List(i), 9) Like UCase(textInput.Text & "*") Then<BR> formName.dropList.Selected(i) = True<BR> Exit Sub<BR> End If<BR> Next<BR><BR> End Sub<BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default I obviously have too much time...

    ...on my hand, or I wouldn&#039;t do this:<BR><BR>function handleChange() {<BR>&nbsp;&nbsp;&nbsp;&nbsp;for (var i = 0; i &#060;= formName.dropList.ListCount - 1; i++) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;var sListItem = formName.dropList.List(i)+"";<BR>&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var sTextInput = textInput.Text+"";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;if (sListItem.substr(0, sTextInput.length) == sTextInput) {<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;formName.dropList.Selected(i ) = true;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;<BR>&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp ;&nbsp;&nbsp;&nbsp;}<BR>}<BR><BR>This is untested, so don&#039;t come back if it doesn&#039;t work. :-)<BR><BR>Oliver.

  3. #3
    Join Date
    Dec 1969

    Default That's not even legal VBScript...

    ...since VBS doesn&#039;t support the LIKE function/operator.<BR><BR>So you&#039;re really lucky it got written (not converted) correctly for you.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts