Set the value of jplist-drop-down after reloading - javascript

I have a jplist dropdown list to change the sort field. When changed I am adding the value to php session.
When reloading the page, I would like the value of that field to be the option selected on the sort dropdown list, but cannot find information on how to do it.
Have tried adding class active, selected, set default=true to the field and the remaining to false. All to no avail.
Anyone?

Found out about deepLinking after reading the docs. It´s exactly what I needed.

Related

How to set cascade select2 value onClick

I have three select2 lists next to each other, first independent, second dependent on first, third dependent on second (cascading lists), that works as expected when I normally populate them by selecting some options. I have created a dynamic action that fills these items with values that I calculate when I click a button, but after the click, only the first select2 have selected value. The second and third value remains empty. When I check the session, all items have value in them. It appears that when I click the button that for a millisecond list are filled but after that values disappear. So my question is, how do I transfer values from server-side to client-side. I tried to refresh items, I have played with jQuery without success, also I have tried to separate dynamic action to set values separately but nothing worked. Values populate correctly so that is not the problem. Please help
Thank you in advance for your answer.
Is lazy loading checked for the select2 that are subject to this behaviour (Item -> Setting -> Lazy loading)? If so try unchecking it

set up form option as default in a drop down

I have created a driven database drop down menu on my website. It sends the selected value by the user to the database to be checked and returns a specific item.
Everything works perfectly now but I'm trying to pre select the first value so that the user will have the first option as default and can add it to cart directly and they also can choose a different size. So far, I tried 'selected' inside the option in the drop down but it doesn't do anything but displays the value when the page loads.
One last thing to mention, I'm using Ajax function to submit selected value and return result from the database.
I can think of two ways for this.
When the page is requested, make a call to your DB in your server-side code to store that value beforehand.
Use javascript's onload event to select the value as a part of a client-side script. You can use this answer as reference.

Dynamically remove dropdown option from SharePoint form

I'm trying to remove multiple dropdown options from my SharePoint 2007 list, based on the selection of a previous dropdown. I already have Javascript running on the page, so a Javascript/jQuery solution would be ideal. I've read getElementByID can be used to get the specific field I need to remove an option from, and .remove can remove the value, but I can't seem to get the syntax right. For SharePoint, what field name should I be using in getElementByID()? Is there a better solution to this?

Selecting more than one value without checkboxes

Currenty I am using checkboxes to select more than one value in a form. So when creating a new post I can select all the categories it falls into. But the cat list is getting longer and is becoming a bit unmanagable.
I like how wordpress adds tags to each post via ajax. Wordpress has a text input field with autocomplete, you just start typing and then if it's already there (in the db) then it'll show and get adding to a list dynamically. If it's not found in the list then it gets inserted on form submit.
How can I achieve this or similar so that I don't have to use x amount of checkboxes?
Check out this jQuery library. It works on multi selects instead of checkboxes, but the logic and result is exactly what you need.
http://harvesthq.github.io/chosen/
(not affiliated, I've just used it a few times)
One option would be to make use a library such as jquery-autocomplete
https://www.devbridge.com/sourcery/components/jquery-autocomplete/
This makes use of AJAX based functionality and will give you the ability to tweak it based on values stored in a database table. You can make a simple check function that, in the case the value can not be found, the user will have the option to simply press add and insert it into said library.
The rest is jsut a matter of styling and design.

jqgrid multiselect edit form fields

I need a form structure to read from JSON, put the values in a multiselect field in edit form mode(not inline), and let the user set the values for the ones he selected.
I dont know if its possible.
I did this and worked fine: https://stackoverflow.com/a/4985705/1052077
But I still need to associate a value to each of the selected items in the second list, like and input so the user can select the number he wants.
Like "physics - 4" and then grab that number(4) to save server side.
I wanted something like this http://www.trirand.com/jqgridwiki/doku.php?id=wiki:jquery_ui_methods#column_chooser
But the ones I found were only accepting the columns values, not any kind of source value.
Thanks in advance!
You can use the multiselect widget directly without the columnChooser. The last version of the widget you can find on the github.

Categories