Friday, July 26, 2013

#SharePoint 2010 | Adding a variable to form submit ddwrt:GenFireServerEvent

Problem:

Want to submit a form to a custom page, with an additional calculated information, such as a querystring.

Solution:

Since the content within ddwrt:GenFireServerEvent is XSLT, we need to create a variable. If we want to call a JavaScript function, it will not be a problem, because the "call" to the function will be appended to the submit event and will only be executed when the button is actually clicked.

//save the execution of a JavaScript function with a static parameter and a calculated one based on a selected tab option
<xsl:variable name="actionAuthor">' + getActor("PR",$(".nav-tabs .active").index()) + '</xsl:variable>

//set the input redirection link to a page and an additional querystring value with the XSLT concat method
<input class="submitFormInput" type="button" onclick="if(!ValidateForm()) return false; { ddwrt:GenFireServerEvent(concat('__commit;__redirect={../../../SitePages/Tasks.aspx?taskSubmittedTo=',$actionAuthor,'}'))}"/>

No comments:

Post a Comment