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?
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');
});
ASKER
I tried and got this for example:
TypeError: $("input[name=\"make\"]"). val(data.s tyleHolder [0].makeNa me).toUppe rCase is not a function
[Break On This Error]
$('input[name="make"]').va l(data.sty leHolder[0 ].makeName ).toUpperC ase();
TypeError: $("input[name=\"make\"]").
[Break On This Error]
$('input[name="make"]').va
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here is a sample I threw together.
http://jsbin.com/OjEpicu/1/edit?html,js,output
http://jsbin.com/OjEpicu/1/edit?html,js,output
x='lower case';
$('div').html(x.toUpperCase());
$('input').val(x.toUpperCase());
<div></div>
<input type="text">
ASKER
Awesome. That nailed it. Thanks for taking the time!
$('input[name="year"]').va