I have a form in which the user can save. In this form I have a dynamic SELECT, when user chooses an option with the event ONCHANGE I get the result of another SELECT. The problem is that when user loads his saved form I need to select with JavaScript his selected option(saved before) but I can't to get the onchange event to load the other select.
This is using jquery. On the dom ready, you select the value for your first select box, then run the function to populate the second select. Next, you're selecting the right value for that second box. On the change, you re run the function to populate your second select
$(document).ready(function(){
$("#firstselect").val(the value you wanted for the first select);
function that populates values of your second select box();
$("#id of your second select").val(the value you wanted for the second select);
$('firstselect').change(run your function that populates your second select)
});
Related
For example I have many many rows which contains 2 columns: checkbox and input, and popup window with editing. In DataSource I have 'Update' event, which call method for updating from controller.
Question: Is it possible to make such situation: User check checkbox on first row -> open popup for second row -> submit changes. Only second row should be updated, not all.
I want pass to server item only from current row. Actual result is that all changed rows passed to method 'Update'
This situation appears because in my application combined "incell" and "popup" editing for Kendo Grid.
When you create a jqgrid there is a default button on the bottom of the grid that allows you to create new records.
However, when you open the modal, all input fields are empty.
In my situation I need this button, but I also need the exact same thing but with the possibilty of adding a few parameters so some of the fields are already filled in. The parameters would come from the selected row at that moment.
Like when I click a row where the date is set to 01/01/2099 i need the add-modal to open with the date already set to that date.
You can use beforeShowForm or afterShowForm to make any changes in the Add Form during opening. For example you can read the values from currently selected row and fill some fields of the form with new values. To be open Add form on click or double-click on the row you need just call editGridRow inside of onSelectRow/ondblClickRow callback.
I need help in figuring out the event that is fired when I select a dropdown value from dijit.form.Select. I already know of the onChange event and would like to know an event which fired even when the value is not changed.
Use Case
I am using dijit.form.Select in my project. I have some values like {Multiple,a,b,c,d} in this select drop down. When I select Multiple then it launches the pop up dialog. When I select other values a,b,c or d then that value gets set in that drop down.
Currently I catch onChange event to check if user has selected "Multiple" value so that I can launch the pop up dialog.
Now here is one issue. 1. Lets assume that by default selected value is a. 2. Now I select Multiple, onChange gets fired and pop up dialog gets launched. 3. Now again if I select Multiple then onChange event won't be fired and thus code would not launch pop up dialog.
I want to launch this dialog every time user selects "Multiple" value in the dropdown. Any suggestions to do this? I have tried useing onClick, onBlur and onFocus events but they are not of much use to me.
Please help.
You can Capture the 'onExecute' event of the dropDown of the dijit.form.Select widget for this behaviour. However, keep in mind that you wont get the newVal as an argument to the function for this event. to get the new value, use the following line as the first line of your function:
var newVal = this.focusedChild.option.value;
This will work for sure :)
When you click on a row in jqgrid it gets "selected" (applies some coloring and styles), other "selected" rows get deselected. However, when I click on an input button element in one of the cells in a row nothing happens... the row is not "selected". How would I make the clicking of this button (or link or whatever) cause the row to be "selected" (and deselected when a different row is clicked)?
Solution:
In the gridComplete method of jqgrid I can attach a click handler to each button, get the ID of the button's parent row and then call jqgrid's setSelection method on it, passing in the required row id as a parameter.
$('#mygrid').find('input[type=button]').each(function() {
$(this).click(function(){
var therowid = $(this).parents('tr:last').attr('id');
$('#mygrid').jqGrid('setSelection', therowid );
});
});
On "tricky" thing about this is that instruction on the jqgrid website show two different ways to go about doing this. The above uses the new API which does things rather differently so you will find a mix of suggestions online that switch between this new API and the older one.
Hello sir I am new to the jsp and ajax world. my problem is
If i select one combo option then it should change the other combo options dynamically without submit button press.
for example if i select the country then it should shows their states in other combo.
I am using servlet & JSP and MS-ACCESS as backend. please reply as soon as possible.
THANKING YOU....
You need:
A piece of JSP which returns a string which can be parsed in javascript to create a list of possible combobox items (value, name) to select in the SECOND combobox, based on a VALUE which can be selected in the FIRST combobox
A piece of javascript which receives the onChange event of the FIRST combobox and uses the then selected value to create a XMLHTTP-request to your JSP (at 1)
A piece of javascript which you can pass to the XMLHTTP-request onReadyStateChange event to execute, which reads/parses the parseable string (from 1) and fills the second COMBOBOX with those values
Good luck