editform.aspx, extra submit button

Apr 14, 2014 at 1:44 PM
In this form there is the SharePoint:SaveButton and the SharePoint:GoBackButton.

I've added a new button called Submit.
In the onclick, I present a question and if answered in the affirmative, I'd like the form to submit as usual like the user click the SharePoint:SaveButton.

I've seen example that have the line "return true;" but this is not working for me. I just stay on the same page and no save has occurred.
I've tried using "submit();" but that does not work either.
Any suggestions?
Apr 15, 2014 at 11:40 AM
You don't need a new button to do this. You can use the function "PreSaveAction()" to handle form validations, confirmations, etc. after the user clicks the normal save button on the form. SharePoint forms will recognize the PreSaveAction() function and wait for a return of 'true' from that function before it commits the data and closes the form. If your result returns 'false', the form processing stops after the PreSaveAction.

Apr 15, 2014 at 2:16 PM
this worked great, thx Geoff

Would you have an answer for this:
get selected value for "choice" field before saving using spservices

I've tried several things I've found online but none seem to work.
this seems like it should work but I get "undefined"
$("select[title='fieldName: Form_x0020_Status']").val();.

My form field is called @Form_x0020_Status with a title of Form Status.
I want to see if this choice field has changed before its saved so if its a particular value, I want to ask a question of the user that may cause them to abort their save.
I already have the value in the list before populating the form so I do have something to compare to.

Apr 16, 2014 at 12:35 PM
Your selector for the choice field is almost there. The select tag's 'title' attribute is actually the display name of the field. So, try....
$("select[title='Form Status']").val()
Apr 16, 2014 at 2:27 PM
thank Geoff but I still get undefined.
here is my form code...see anything there?

<td width="190px" valign="top" class="ms-formlabel">
<H3 class="ms-standardheader"> <nobr>Form Status<span class="ms-formvalidation"> *</span> </nobr> </H3> </td>
<td width="400px" valign="top" class="ms-formbody" id="FormStatus">
<SharePoint:FormField runat="server" id="ff2{$Pos}" ControlMode="Edit" FieldName="Form_x0020_Status" __designer:bind="{ddwrt:DataBind('u',concat('ff2',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Form_x0020_Status')}"/>
<SharePoint:FieldDescription runat="server" id="ff2description{$Pos}" FieldName="Form_x0020_Status" ControlMode="Edit"/>
Apr 16, 2014 at 3:06 PM
here is the SPServices code
$(document).ready(function() {
alert($("select[title='Form Status']").val());
Apr 16, 2014 at 4:38 PM
You should use a DOM inspector like Firebug to look at the title of the 'Form Status' field. In recent updates, if the column is required, the title will be 'Form Status Required Field'. If you're going to do stuff like this, you'll need to get familiar with DOM inspection anyway, otherwise you're flying blind.

Finally, your last post above isn't "SPServices code". You're really just using jQuery at this point.

Apr 17, 2014 at 1:26 PM
Also, the DOM content you posted looks radically different than what I'm used to seeing in a new or edit form. In the DOM content you posted, there isn't even a select tag included. I don't know what that content is actually referring to. The first part looks fairly typical for the field label (left side of the form). That's what's included inthe H3 tag. The beginning of the following TD tag looks fairly normal too. Everythig after that TD tag looks foreign to me.
Apr 17, 2014 at 5:20 PM

It's the server side view of the control, rather than what shows up in the DOM. If you customize a form with SPD, this is what you see in the DFWP.

Apr 17, 2014 at 7:44 PM
Ahhh, that's why it looks foreign to me. Our server farm admins have locked down SharePoint so that no SPDesigner connection is allowed.