Yii Framework Forum: Auto populating value hide if I click on the input field - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Auto populating value hide if I click on the input field Rate Topic: -----

#1 User is offline   mrs 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 52
  • Joined: 05-September 12
  • Location:Bangladesh

Posted 14 April 2015 - 03:42 PM

I am using http://demos.krajee....ails/typeahead.


I have 3 input fields in my form and these are Country, State and City. I am using Typeahead in Country input field to populate country.

Typeahead display data as following-

US - DC

US - MD

UK - London

If I choose "US - DC" then in Country field I display "US" and in State field "DC".

Here, the problem is- then if I click on Country input field then it replace the value "US" with value "US - DC". And if I click on State input field it remove the value "DC" from the field.

I am using following code-


$("#country-id").bind("change", function(e)
{ 	
   var country = $(this).val();  	
   var t = $(this);  	
   $.ajax({ 		
   url: './state',    	
    type: 'post',    	
    data: 'id='+country,    	
    cache: false, 		
	dataType:'json',      	
	success: function(data) {        	
      if(data.state != "")            	
        $("#state-id").val(data.state); 			
      var countryVal = country.split("-",1);        	
      console.log(countryVal);        	
      t.val(countryVal);    	
   }	
 })   
});


What I am missing here?
Explore and Enjoy Yii 2...
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users