[SOLVED]how do you check if option elements exist
I'm creating a HTML application.
How can you check with VBscript if option element exists in the html code?
I have to check if there are options inside the select element like in this example:
Code:
<select name="LangChooser">
<option value="sp">Spanish</option>
<option value="en">English</option>
</select>
...OR if there are not option elements like in this example:
Code:
<select name="LangChooser">
</select>
Thanks!
Re: how to check if option element exists
Try something based on this:
Code:
<script language="VBScript">
Option Explicit
Sub CheckLang ()
Dim selectElement
Set selectElement = document.getElementById("LangChooser")
If selectElement.options.length = 0 Then
alert "No options"
Else
alert "Number of options = " & selectElement.options.length
End If
End Sub
</script>
Re: how to check if option element exists
Quote:
Originally Posted by
His Nibbs
Try something based on this:
Code:
<script language="VBScript">
Option Explicit
Sub CheckLang ()
Dim selectElement
Set selectElement = document.getElementById("LangChooser")
If selectElement.options.length = 0 Then
alert "No options"
Else
alert "Number of options = " & selectElement.options.length
End If
End Sub
</script>
Thanks a lot! Works perfectly! :thumb::thumb: