Share via

SP List validation refresh page on submit does not retain custom dropdown value

Shri-6058 326 Reputation points
2020-11-20T06:47:25.297+00:00

I have a a script editor having dropdown control. The value automatically fills via Jquery on load.

<select name="items" id="ctl00_DropDownChoice">
<option value="_select">_select</option>
</select>

I am assigning selected text value to hidden SPlist text field. The text everything retains but the custom dropdown value selected doesn't retain but display "_Select" instead of selected value when submit list item and when missing required field validation happens.

I tried global variable assigning selected values and document ready set dropdown value with global variable, it doesnt work. A kind of postback is what required. Please help.

Microsoft 365 and Office | SharePoint Server | For business
Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft 365 and Office | SharePoint Server | Development
0 comments No comments

Answer accepted by question author

Baker Kong-MSFT 3,801 Reputation points Moderator
2020-11-23T02:25:30.887+00:00

Hi @ShridharHegde-2034,

The options filled in the dropdown control come from an asynchronous request. When the page reloads, $('#CT100_DropdownChoice').val(selItem); won't take effect as there is no such an option at that time.

So you can put the above snippet in the callback of the request:

41639-image.png

Test:

41742-test.gif

Best Regards,
Baker Kong


If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Shri-6058 326 Reputation points
    2020-11-24T04:25:58.613+00:00

    That's exactly what its working. Thanks so much!

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.