Hi,
I am trying to get the id value of a selected item id from a select drop down using my B4J app.
In my HTML I have:
In My B4J project (non-UI) I have a button and when I click on it I have tried to get the selected option id without much luck.
Here is what I have tried..
I can't work out how to get the id of the selected item, such as 'item2'
In JavaScript I can get the value like:
Any ideas on how to get the selected option ID (for example, item2) of the selected item ?
I am trying to get the id value of a selected item id from a select drop down using my B4J app.
In my HTML I have:
HTML:
<select id="MyList">
<option id='item1'>this is item 1</option>
<option id='item2'>this is item 2</option>
<option id='item3'>this is item 3</option>
</select>
In My B4J project (non-UI) I have a button and when I click on it I have tried to get the selected option id without much luck.
Here is what I have tried..
B4X:
Log(ws.GetElementById("MyList").GetProp("id").Value) ' returns MyList
Log(ws.GetElementById("MyList").GetProp("value").Value) ' returns 'this is item 2'
Log(ws.GetElementById("MyList").GetProp("selectedIndex").Value) ' returns 1 (when the second item is selected)
I can't work out how to get the id of the selected item, such as 'item2'
In JavaScript I can get the value like:
JavaScript:
alert(document.getElementById("MyList").options[document.getElementById("MyList").selectedIndex].id); // returns 'item2'
Any ideas on how to get the selected option ID (for example, item2) of the selected item ?