Link to home
Start Free TrialLog in
Avatar of tjyoung
tjyoung

asked on

Trying to change to uppercase values in input fields populated by json

Hi,
I have some code shown below that populates a few text fields but the data is mixed case and I need to change it to uppercase. Any idea how I could do it given below?

$( "#getvin" ).click(function() {
$.post("trades/vin_decode/",{ vin: $('input[name="vin"]').val() },
	function(data){
$('input[name="year"]').val(data.styleHolder[0].year);
$('input[name="make"]').val(data.styleHolder[0].makeName);
$('input[name="model"]').val(data.styleHolder[0].modelName +" "+ data.styleHolder[0].categories["Vehicle Style"]);
$('input[name="trim"]').val(data.styleHolder[0].trim.name);
$('input[name="engine"]').val(data.styleHolder[0].engineSize + " Litre - " + data.styleHolder[0].engineCylinder +" Cylinder Engine");
$('input[name="transmission"]').val(data.styleHolder[0].transmissionType);
$('input[name="driveType"]').val(data.styleHolder[0].attributeGroups.DRIVE_TYPE.attributes.DRIVEN_WHEELS.value);
$('input[name="fuelType"]').val(data.styleHolder[0].engineFuelType);
	},
    'json');
  });

Open in new window

Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Just add .toUpperCase();

$('input[name="year"]').val(data.styleHolder[0].year).toUpperCase();
Avatar of tjyoung
tjyoung

ASKER

I tried and got this for example:

TypeError: $("input[name=\"make\"]").val(data.styleHolder[0].makeName).toUpperCase is not a function
[Break On This Error]       

$('input[name="make"]').val(data.styleHolder[0].makeName).toUpperCase();
ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here is a sample I threw together.

http://jsbin.com/OjEpicu/1/edit?html,js,output

x='lower case';

$('div').html(x.toUpperCase());
$('input').val(x.toUpperCase());

Open in new window

  <div></div>
  <input type="text">

Open in new window

Avatar of tjyoung

ASKER

Awesome. That nailed it. Thanks for taking the time!