Thursday, May 9, 2013

Submit the form when a drop down menu item is selected in Webadvisor


In field output of a VAR variable, enter the following:

OUTPUT.DATA := '<script type="text/javascript">'
OUTPUT.DATA := "document.getElementById('VAR1').onchange = submit;"
OUTPUT.DATA := 'function submit() {document.datatelform.submit();}'
OUTPUT.DATA := '</script>'

In this case, VAR1 field contains the drop down menu. This code needs to be parsed after VAR1. For instance, if you insert the above code in VAR2 output field, VAR2 needs to be below VAR1 in UI Form Field Sequence.



Note that this has only been tested with standalone webadvisor. I am not sure if this will work with webadvisor webpart inside colleague portal. If it does, the document and field name may need to change accordingly.

2 comments:

  1. I was using this script document.getElementById("datatelform").submit();, however, it is not working properly. This working fine for me: document.datatelform.submit();}

    Thank you!

    Huy

    ReplyDelete
  2. The form ID may not be "datatelform", so that's why the lookup "getElementById" doesn't work.

    ReplyDelete