Search code examples
javascriptjqueryinfopath2010

Fire event by "value="Submit" type="button" - Javascript


I have a browser Infopath form which has only one submit button, and it generates code in browser as below.

<input tabIndex="0" title="" class="b_ajsA2MO9TIq7hnY0_0 u_ajsA2MO9TIq7hnY0_0 s_ajsA2MO9TIq7hnY0_0" 
id="ctl00_m_g_7642489c_426f_476c_9bd0_b2a7e510466e_FormControl0_V1_I1_B1" style="text-align: center;" onclick="return (Button.OnClick(this, event));" onfocus="return (Button.OnFocus(this, event));" type="button" buttonid="CTRL1_5" OriginalId="V1_I1_B1" FormId="ctl00_m_g_7642489c_426f_476c_9bd0_b2a7e510466e_FormControl0" ViewDataNode="2" direction="ltr" wrapped="true" ScriptClass="Button" value="Submit"/>

I need to redirect to a page on button click, ids are generated dynamically. Only way to achieve this is get

 "value="Submit" type="button" 

and call the event. Can anybody suggest the code to fire redirection?


Solution

  • Use event delegation for dynamically created elements

    $(document).on("click" , "input[value = 'Submit'][type='button']" , function() {
    
             window.location.href = 'someurl'
    });