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

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.

0

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
    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 Sep 9, 2015 at 19:48

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .