0

I'm trying to store all values from a drop down box into variables within my android application. I'm trying to get all options from the below into strings in my app;

<select name="cardId" id="select_card_no" onfocus="null" onchange="null">
<option value="">Choose card number</option>
<option value="010607655930" >010607655930</option>
<option value="050538806749" >050538806749</option>
<option value="054100790989" >054100790989</option>
</select>

I've been using code like this to intially log through parts of the site;

public void onPageFinished(WebView view, String url) {
                if(url == "https://oyster.tfl.gov.uk/oyster/entry.do"){             
                    String ausername = "abcde";
                    String apassword = "12345";
                    view.loadUrl("javascript:document.getElementsByName('j_username')[0].value = '"+ausername+"'");
                    view.loadUrl("javascript:document.getElementsByName('j_password')[0].value = '"+apassword+"'");
                    view.loadUrl("javascript:document.forms[0].submit()");
                }

But was wondering how you could possibly get text back from the current Webview state, can you somehow convert loadUrl into a string;

String ddl = view.loadUrl("javascript:document.getElementById('select_card_no')");
r0bb077
  • 732
  • 2
  • 11
  • 33

1 Answers1

0

Possible duplicate question. You may want to check out the answer to this one:

android - get Text out of webview

Also, there might be an overall better solution than using this webview approach you're trying. That url does have a developer api: android - get Text out of webview

You may want to try and see if you can get waht you need out of that.

Community
  • 1
  • 1
SBerg413
  • 14,515
  • 6
  • 62
  • 88
  • Thanks for the reply. i saw that link the second after I posted this, but you said you saw a developer API for this? I know their general API but haven't seen one for the Oyster card as of yet! – r0bb077 Sep 29 '13 at 12:24
  • You know what - all i saw was the general API. So, not really sure they have an api for exactly what you need. – SBerg413 Sep 29 '13 at 14:20