Question

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";
}
    </script>
    <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.

Was it helpful?

Solution

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

Try to remove the #.

Documentation here

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top