I created a Cascading of Dropdown list for Country state city in my application using Ajax request and Select Box. My application gathers information about users ie personal info etc. In my application there is an option to Edit the entered fields.. upon clicking the edit button the personal information page is populated with previously entered data. Now i need help to show the selected value that is which country, state and city is selected by the user in my select box dropdown. Please help!!
In your view assign the previously selected value to a javascript var. Then when the ajax request succeeds, set the dropdown value from the var.
Here's an example using jQuery.
// set a js var from a php var passed to the view from CI
var previous_country = <?=$previous_country?>;
$.ajax({
// your ajax options here (url, datatype, etc)
success: function(response){
// code to populate dropdown here
// then set the dropdown value to change the selected item:
$('select#country').val(previous_country);
}
});
Related
I have a Select2 multiple select box on a form, for users to select the countries they have previously visited. I'm using Laravel 4 and when the form is submitted, it then validates all form fields and redirects back to the form if any validation errors have occurred - repopulating the form with the users previous input ( using Input::old('???') ).
My questions is how can I reapply the users previous selections to the Select2 multiple select box, using the data stored in Input::old('countries[]') ?
Where in my JavaScript code would I add the ID's of the users previous selections?
$(document).ready(function() {
$('#inputCountries').select2(); // How do I add selections?
});
I think you just need to provide the array of IDs of countries as an argument of selected items. Might need to use one of array_keys to get just the IDs passed into the selected items array.
I'm trying to create a webpage where a user can click on an item inside a gridview and have that rows data display in another page. I cannot figure out how to set it up so only the selected row's information is displayed in (I am thinking I will use a form view to display the data on the second page) the form view on the second page. Any suggestions?
Thanks!
Jake
If you have just a couple of columns i did suggest you to use QueryString to pass values between pages. Lets say there are two such values you want to pass to another page:
Response.Redirect("default2.aspx?firstvalue=" + yourfirstvalue + "&secondvalue=" + yoursecondvalue");
// this will set the values you want to pass on your gridview page
Request.QueryString("firstvalue")
// this will retrieve the first value from URL from your second page
If you want a neat lookin URL then i would suggest you to use Session variables.
in title i have mention what im tryin' to achieve, here is the code i'm working with
i have colModel
....
editoptions:{value:getNames()}
....
function getNames() {
var Names = $.ajax({
url: '/Account/GetNames',
async: false
}).responseText;
return Names;
}
Now when i fire $("#grid").trigger("reloadGrid"); the grid is getting reloaded but the
Action GetNames is not geting called, so the select list on my add/edit modal is not filling up the latest data coming from server..
Im using jquery ui tabs, 2 tabs each tab reders a jqgrid, so let say in 1st tab i add a Name, now on 2nd tab when im adding Contact i show Names in the select list, since both the grid are loaded once, im tryin' to reload the tab on demand, now grid getting reloaded but the script function which's makes ajax request to get Names is not getting hit...
Note: things are working fine for the 1st load when page is loaded, ie my select list is getting populated if i refresh the page after i added Names on my 1st tab..
How can I set an onchange event to a tag?
I want to transfer the new value to the server without klicking the submit button (therefore in an ajax way)
Grails datepicker tag implemention renders a fixed number of select tags based on the precision that you choose. However, no onchange attribute is added to any of these select tags. The id of each select tag is the id that you specify in the datepicker tag appended by the type of data that each select shows. Eg. the select box for day has id "yourDatepickerTagId_day", the month select tag has id "yourDatepickerTagId_month" etc. To bind the "change" event to any of these select tags you will have to use some custom javascript to handle these events. If you use jQuery, you can use something like this:
$(document).ready(function(){
$("select[id ^= yourDatepickerTagId]").change(function (){
// Do your stuff here...
});
});
I'm building a simple mvc3 app using jqgrid.
My form currently calls a function in my controller that searches the database based on what the user has inputted into the textboxes after clicking on a search button.
I want to only display the jqgrid with the information after clicking on the search button.
Any idea on how to do this?
Thanks
You need to pass an additional variable to the controller to check whether you have selected a button or not.
example:
('#grid').jqgrid({
...
url: '/Controller/Action/?additionalvariable = ' + variable,
...
)};
where the value of the variable is true or false depending on whether you have searched or not.