html - Modify below function to select item from dropdown -


i have following delphi code fill form on twebbrowser:

procedure setfieldvalue(theform: ihtmlformelement; const fieldname: string; const newvalue: string);    var      field: ihtmlelement;      inputfield: ihtmlinputelement;      selectfield: ihtmlselectelement;     textfield: ihtmltextareaelement; begin   field := theform.item(fieldname, '') ihtmlelement;   if assigned(field)   begin     if field.tagname = 'input'     begin       inputfield := field ihtmlinputelement;       // make change below catch checks , radios.       if (inputfield.type_ = 'checkbox') or (inputfield.type_ = 'radio')       begin         if newvalue = 'y'           inputfield.checked := true         else           inputfield.checked := false;       end       else         inputfield.value := newvalue;     end     else if field.tagname = 'select'     begin       selectfield := field ihtmlselectelement;       selectfield.value := newvalue;     end     else if field.tagname = 'textarea'     begin       textfield := field ihtmltextareaelement;       textfield.value := newvalue;     end;   end; end; 

html source looks example:

<select name="xosid">    <option value="" selected>-- choose 1 --</option>    <option value="first">this one</option>    <option value="second">another</option> </select> 

i modify above function able select dropdown 'another' without knowing value...

any suggestions?

thanks in advance,

zsolt

to able select dropdown 'another' without knowing value

so index ? option number 2 (starting zero) ?

let's start searching data type in google

the 1st link msdn specifications datatype in microsoft internet explorer. right can see selectedindex: integer property.

so code like

else if field.tagname = 'select'     begin       selectfield := field ihtmlselectelement;       selectfield.selectedindex := 2;     end 

and going google, 3rd link me ready source code example using property.


Comments