I have an infopath form web part on my web page along with a CEWP. I'm using javascript in my CEWP to set a field on my Infopath form to some value when a button is clicked. For some reason I can't get the Infopath field to update.

    <script type="text/javascript">
    function filter()
{       document.getElementById("#ctl00_m_g_01d631bf_e556_4975_acbb_226c880bfd44_FormControl0_V1_I1_E1").Value= "TestValue";
    <button onclick="setTimeout(filter,3000);" type="submit">Click</button>

The #ctl00_m_g_01d631bf_e556_4975_acbb_226c880bfd44_FormControl0_V1_I1_E1 is the ID of my text field.

  • Can you post the JavaScript Code? Commented Feb 18, 2016 at 21:44
  • Just edited my original post with code. Commented Feb 18, 2016 at 21:49

1 Answer 1


It seems to me you used a # in the getelementbyid where it should not be.

Try to remove the #.

Documentation here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.