I want to create an object array that maps the first drop down key with second drop down value... Need to fetch object array from phpSimilarly on selecting tier drop down, fee drop down should gets updated as well as fee value should be in the input box.
Example : if i select Tier 1 in first drop down , then it should change "tier 1- 100 rupees" in second drop down and also the input field should have updated value 100..
define('TIER_LIST', json_encode(
array(
'1' => 'Tier 1',
'2' => 'Tier 2',
'3' => 'Tier 3',
)
));
define('FEE_LIST', json_encode(
array(
'1' => 'Tier 1 -100 Rupees ',
'2' => 'Tier 2 -200 Rupees',
'3' => 'Tier 3 -300 Rupees',
)
));
$tierList = json_decode(TIER_LIST,true);
$feeList = json_decode(FEE_LIST,true);
// drop down fields
<select class='browser-default selectField' id="TierSelection">
<option value="">Choose your option</option>
<?php foreach($tierList as $value => $text) { ?>
<option value="<?php echo $value; ?>"><?php echo $text; ?></option>
<?php } ?>
</select>
<select class='browser-default selectField' id="FeeSelection">
<option value="">Choose your option</option>
<?php foreach($tierList as $value => $text) { ?>
<option value="<?php echo $value; ?>"><?php echo $text; ?></option>
<?php } ?>
</select>
<input type = "text" id = "feeValue">
var objArray = {tierdropdownkey : feedropdownValue } --->doubt in this creation # should not hard code
$("#tierDropDownId").change(function()
{
var ddText = $(this).val();
$.each(objArray,function(key,value)
{
if(ddText == key)
$("#feeDropDownId").val(value);
});
});


