Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm having some real problems trying to fire a really simple piece of a Javascript code that I intend to run on the click of a button.

I think the problem is the location of the script or another trivial error but after scouring various blogs and threads I still haven't found my solution.

I am attempting to change the default SharePoint 'collect information from user' form such that there would be two buttons (OK, cancel) as opposed to the standard three - Save draft, complete task, cancel - which, by default, have these onclick attributes:

Save Draft

onclick="javascript:     {ddwrt:GenFireServerEvent(concat('__update;__commit;__redirectsource;__redirectToList={',ddwrt:EcmaScriptEncode($ListName),'};'))}

Complete Task

 onclick="javascript: {ddwrt:GenFireServerEvent(concat('__update;__workflowTaskComplete={',ddwrt:EcmaScriptEncode(string($Id)),'*',ddwrt:EcmaScriptEncode($ListName),'};__commit;__redirectsource;__redirectToList={',ddwrt:EcmaScriptEncode($ListName),'};'))}


onclick="javascript: {ddwrt:GenFireServerEvent(concat('__cancel;__redirectsource;__redirectToList={',ddwrt:EcmaScriptEncode($ListName),'};'))}

My desired functionality is that there be a yes/no drop down which is used to determine whether the 'Save Draft' or 'Complete Task' default behaviour is executed.

I was hoping that I would be able to use something like:

<input type="button" name="btnMarkSubmited" value="Complete Task"   OnClick="checkIfFinal"></input>

with a simple js function like:

function checkIfFinal()
var $status =     $('select[id*=ctl00_PlaceHolderMain_TaskForm_ff2_1_ctl00_DropDownChoice]');

Unfortunately, this doesn't seem to work. I have added my function name to _spBodyOnLoadFunctionNames.push and verified that the function is added to its array but when the button is clicked I get an uncaught reference exception. I have the function saved in an external js file that is referenced from a second asp:content tag, like so:

<asp:Content id="Content2" runat="server" contentplaceholderid="PlaceHolderAdditionalPageHead">
<script src="../../Site configuration/jquery-1.9.1.min.js" type="text/javascript" language="javascript"></script>
<script src="../../Site configuration/showHide.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript" language="javascript">

I am grateful for any help that anyone is able to offer and will give as much information as I can, if this is not enough.

share|improve this question
add comment

migrated from stackoverflow.com May 30 '13 at 9:27

This question came from our site for professional and enthusiast programmers.

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.