Hi i am using dropdown for display the timezone.The timezone values are come from database.Whenever the user change the value I need to alert the new timezone.For example if user change the time GMT+5.30 to GMT+6.30 then I want to alert GMT+6.30.Here the the dropdown values coming as an array?What can I do to get the values?
If you're using select and you have set values for your options, you can:
$("select#dropdown").change(function(){
alert($(this).val());
});
To do this, you need the jQuery framework. http://www.jquery.com/
checkout http://www.texotela.co.uk/code/jquery/select/ plugin for handling select element, very handy.
Related
Folks
We are creating the application and used the jquery as discussed in this website
we are using multiple select dropdown with checkboxes. ( as in the screenshot attached)
The issue is
we cannot update the return result of the ajax call.
eg
if i select the date to and date from then the result between these two dates should be filtered and should be displayed in the multiple select dropdown with checkboxes.
Let me know if there is any other way to implement the same.( multi select dropdown along with the checkbox functionality).
You want to use `$("select").multiselect('refresh');`
//create new object with ajax data
var opt = $('<option />', {
value: "new value",
text: "new text"
});
opt.appendTo(jqselect );
jqselect.multiselect('refresh');
I use the chosen (from jquery-chosen).
In chosen you can specify a filter, where you can use select with multi or not.
I am working on multiselect group. Here is the link i have populated some data in the multiselect group and the users can select their requirements in that.
http://vignesh.gvignesh.org/chose/chose.php
Here once show selected button is clicked i am calling javascript function.
function chos()
{
var a = $(".chzn-select").chosen();
alert(a);
}
it is not showing the selected values in alert box. Some [object][object] is displayed.
i dont know how to get the selected values. If my javascript function for getting the values is wrong kindly let me know the new function.
Thanks in Advance.
Just use $("#chossen").val(), which returns an array of values that are currently selected.
To get the actual option elements that are selected, try $("#chossen").find("option:selected");, and then loop through those (obviously) - in case you want to get their text.
Doing a search form in PHP YII in which i need to enter 2 dates field Startdate and enddate, after submitting i will be fetching all the records from table where the contacteddate falls between these start and end date.
The problem is after submitting my textbox values are vanishing. How to retain after submitting?
You could use ajax to retrieve the results, instead of the default submit, that way your filter values will not change. The default submit behavior loads(navigates) to a url, hence your values disappear.
You can use CHtml::ajaxSubmitButton() to easily implement this functionality. A sample:
echo CHtml::ajaxSubmitButton(
'AjaxSearch', // label
$url,// url that will search
array('update'=>'#resultdiv'),// the element with id 'resultdiv' will be updated with the search result
$htmlOptions
);
I get the script for selecting the previous selected value in list box from Jquery get the pervious selected value in listbox
It is fine for the individual select boxes.
I have multiple select boxes. I wrote the change event with the class name. It returns undefined. Please refer this fiddle
http://jsfiddle.net/uW2ND/1/
How can i get the previous selected value of the each selected list box with this.
You forgot to include the code that actually sets the value of the jQuery-data to the previous value!
Check out this solution: http://jsfiddle.net/uW2ND/2/
This fiddle illustrates the proper way to persist the previous value. More specifically, it stores each select box's previous value in its related data() container. The first time around it would not alert anything, since no previous value is set.
http://jsfiddle.net/KxEKd/1/
I have two select dropdowns, regions and towns. If the region is selected, it updates the towns dropdown with the appropriate towns for that region using Ajax.
I am trying to use an imagemap to select the dropdown for region, which should update the towns, but it is not. The value for region dropdown gets selected but the ajax does not fire to update towns. All works fine if not using the imagemap. Is the image map select jQuery below not actually updating the select box the way I think it is? Any ideas?
//ImageMap Selectors
$('area', '#regionmap').click(function(){
$("#region").val($(this).attr('alt'));
});
The onchange event is not fired when an option is selected programmatically. Trigger the event manually by tacking on a call to .change().
$("#region").val($(this).attr('alt')).change();