# Setting aDrop down list in a Webviewer form

**URL:** <https://the.fmsoup.org/t/setting-adrop-down-list-in-a-webviewer-form/3446>\
**Category:** Questions\
**Tags:** scripting, web\_viewer, javascript, plugins, mbs\
**Created:** [March 11, 2023, 2:04pm UTC](https://the.fmsoup.org/t/setting-adrop-down-list-in-a-webviewer-form/3446 "2023-03-11T14:04:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tled](https://avatars.discourse-cdn.com/v4/letter/t/4af34b/32.png) [@tled](https://the.fmsoup.org/u/tled)\
**Post date:** [March 11, 2023, 2:04pm UTC](https://the.fmsoup.org/t/setting-adrop-down-list-in-a-webviewer-form/3446/1 "2023-03-11T14:04:26Z")

</div>

I’m trying to populate a drop down list on a web page.  
I have been able to get other type of fields to work but not drop downs.  
The others that work I used MBS Webviewer functions but couldn’t get them to work with drop downs.

Here are some details. I have never used java. Feel free to laugh at how wrong this may be!!

FORM NAME IS - misADForm  
Webviewer Name is - Web  
I think the item is - #ad\_item\_822\_3913\_0\_0

MBS Form utility gives me this -

MBS( "WebView.SetFormInputValue" ; $WebViewerRef; 1; "ad\_item\_822\_3913\_0"; $Value )MBS( "WebView.SetFormInputValue" ; $WebViewerRef; 1; "ad\_item\_822\_3913\_0"; $Value )

I have tried this with no luck -  
MBS( "WebView.SetFormInputValue" ; "Web"; 1; "ad\_item\_822\_3913\_0"; 3 )

My latest of many Script attempts:

Let(

[

webViewerName = "Web";

windowRef = MBS("Window.FindByTitle"; Get ( WindowName ));

webViewerID = MBS("WebView.FindByName"; windowRef; webViewerName)

];

Case(

webViewerID = 0; "Web Viewer "" & webViewerName & "" Not Found: " &windowRef ;

MBS("WebView.RunJavaScript"; webViewerID; "document.misADForm.#ad\_item\_822\_3913\_0\_0.selectedIndex =1" ) )

)

The Html for the Drop down is -

---

<div class="post-metadata">

**Author:** ![steve\_ssh](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steve_ssh/32/160_2.png) [@steve\_ssh](https://the.fmsoup.org/u/steve_ssh)\
**Post date:** [March 11, 2023, 3:31pm UTC](https://the.fmsoup.org/t/setting-adrop-down-list-in-a-webviewer-form/3446/2 "2023-03-11T15:31:16Z")

</div>

You could try a variant in your last line of non-trivial code shown above.

Instead of:

`MBS("WebView.RunJavaScript"; webViewerID; "document.misADForm.#ad_item_822_3913_0_0.selectedIndex =1" ) )`

Try something like:

`MBS("WebView.RunJavaScript"; webViewerID; "document.forms.misADForm.elements.ad_item_822_3913_0_0.selectedIndex = 1" ) )`

or:

`MBS("WebView.RunJavaScript"; webViewerID; "document.forms['misADForm'].elements['ad_item_822_3913_0_0'].selectedIndex = 1" ) )`

Note that these suggestions are just guesses based on what I think you are trying to do, what I imagine the MBS function does, and what I am guessing the HTML in the target page looks like. So, safe to say that there is a fair amount of speculation going into the above.

Hope this helps, and good luck!

---

<div class="post-metadata">

**Author:** ![steve\_ssh](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steve_ssh/32/160_2.png) [@steve\_ssh](https://the.fmsoup.org/u/steve_ssh)\
**Post date:** [March 12, 2023, 3:02pm UTC](https://the.fmsoup.org/t/setting-adrop-down-list-in-a-webviewer-form/3446/4 "2023-03-12T15:02:54Z")

</div>

p.s. I paid a little bit more attention to the name of this plugin function, and realized that there could be a companion function more appropriate for setting the Select element.

Turns out there is. Per docs on @MonkeybreadSoftware 's site:

[https://www.mbsplugins.eu/WebViewSetFormSelectValue.shtml](https://www.mbsplugins.eu/WebViewSetFormSelectValue.shtml)

p.s. Sorry that I had to delete the post above with the welcome to the Soup. The forum software prohibits me from three consecutive replies (perfectly reasonable restriction), so I deleted that one in hopes that it would help me post this. Welcome to the Soup!

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [March 12, 2023, 10:37pm UTC](https://the.fmsoup.org/t/setting-adrop-down-list-in-a-webviewer-form/3446/5 "2023-03-12T22:37:26Z")

</div>

You can always edit one of your earlier posts if it makes sense to do that.

---

<div class="post-metadata">

**Author:** ![MonkeybreadSoftware](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/monkeybreadsoftware/32/361_2.png) [@MonkeybreadSoftware](https://the.fmsoup.org/u/MonkeybreadSoftware)\
**Post date:** [March 13, 2023, 6:27pm UTC](https://the.fmsoup.org/t/setting-adrop-down-list-in-a-webviewer-form/3446/6 "2023-03-13T18:27:08Z")

</div>

I would also suggest trying [WebView.SetFormSelectValue](https://www.mbsplugins.eu/WebViewSetFormSelectValue.shtml) function.

That code basically only loops over the items in the popup and then on a match sets selected flag on it.

Does that work?
