user7715
user7715

Reputation: 97

Getting form values from outside the form in jsp?

I just want to know if this is possible, let say I have form of a search bar that has a dropdown list that applies to the search with it on the front page and I have links on the side of recent search words which is outside of the form and I want to get the currently selected dropdown value from outside the form is this possible? I'm using spring tool suite.

Upvotes: 1

Views: 313

Answers (1)

Software Engineer
Software Engineer

Reputation: 16110

You could use javascript to copy the value from the drop-down into a hidden input field when the user presses submit. In jquery you'd do something like this: $('#mySubmitButton').click(copyFn);, where copyFn is implemented to do the copy and perform the submit afterwards (although you'll have to stop the form automatically submitting in the first place, this isn't difficult).

Alternatively, you could just widen the scope of the form to encompass the drop-down.

Upvotes: 1

Related Questions