Sharepoint 2007 onClick not finding javascript method
<p>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.</p>

<p>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.</p>

<p>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:</p>

<p>Save Draft</p>

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

<p>Complete Task</p>

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

<p>Cancel</p>

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

<p>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.</p>

<p>I was hoping that I would be able to use something like:</p>

<pre><code>&lt;input type="button" name="btnMarkSubmited" value="Complete Task"   OnClick="checkIfFinal"&gt;&lt;/input&gt;
</code></pre>

<p>with a simple js function like:</p>

<pre><code>function checkIfFinal()
{
var $status =     $('select[id*=ctl00_PlaceHolderMain_TaskForm_ff2_1_ctl00_DropDownChoice]');
if($status=1)
{
    {ddwrt:GenFireServerEvent(concat('__update;__workflowTaskComplete={',ddwrt:EcmaScriptEncode(string($Id)),'*',ddwrt:EcmaScriptEncode($ListName),'};__commit;__redirectsource;__redirectToList={',ddwrt:EcmaScriptEncode($ListName),'};'))}
}
else
{
    {ddwrt:GenFireServerEvent(concat('__update;__commit;__redirectsource;__redirectToList={',ddwrt:EcmaScriptEncode($ListName),'};'))}
}
}
</code></pre>

<p>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:</p>

<pre><code>&lt;asp:Content id="Content2" runat="server" contentplaceholderid="PlaceHolderAdditionalPageHead"&gt;
&lt;script src="../../Site configuration/jquery-1.9.1.min.js" type="text/javascript" language="javascript"&gt;&lt;/script&gt;
&lt;script src="../../Site configuration/showHide.js" type="text/javascript" language="javascript"&gt;&lt;/script&gt;
&lt;script type="text/javascript" language="javascript"&gt;
_spBodyOnLoadFunctionNames.push('setOnChange');
_spBodyOnLoadFunctionNames.push('hideOnLoad');
&lt;/script&gt;
&lt;/asp:Content&gt;
</code></pre>

<p>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.</p>
