1

I have a customized form in SharePoint 2013. I want that on click of the submit button on the list, a value will also update.

Currently on click of the submit button, it is saving the values and redirecting to the home page.

<input type="button" value="Submit" name="btnFormAction" 
 onclick="javascript:{
    ddwrt:GenFireServerEvent('__commit;__redirect={https://homepage.aspx}')
 }"
 style="width: 119px" />

I have created one flag with default value as 0, I want once the user click on the submit button this flag value will change to 1.

2 Answers 2

1

Your buttons are in a SharePoint FORM, so when you add a button the click event is bubbling up to the FORM, and the FORM is submitted.

You have to add JavaScript code to stop that from happing with

event.stopPropagation();

or

event.preventDefault();

See: https://stackoverflow.com/questions/5963669/whats-the-difference-between-event-stoppropagation-and-event-preventdefault

mark the answers as answered to keep StackExchange clean

2
  • This also means that the onclick is never executed and he'll have to handle the saving himself.
    – Akhoy
    Commented Sep 9, 2015 at 15:00
  • the onclick is executed but not propagated (if I have to be symantically correct). So call the saving function after you have executed your own stuff. The same is done in your jQuery solution Commented Sep 9, 2015 at 19:48
0

Remove the onclick from the button and write an onclick event in jQuery like $('input[name="btnFormAction"]').click(function(){}) and use REST api / JSOM to update the value to the list. Here you can also redirect to the homepage.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.