I'm having trouble displaying the results of a PHP/JSON array in a php field.
The value of interest is number 9... 'ptm:yes/no'. This is based on whether a field in a db is null or not null. This is obviously working because the correct data is returned.
I have tested that I am getting the correct results like this:

However I'm having trouble getting this to display in a php based form. Item number 3
<tr>
<td>
<span class="qText" name="was_PMV"> 3. Did file start as a PMV?</span>
</td>
<td>
<select class="qAns" name="was_PMV_a">
<option value="No">No</option>
<option value="Yes">Yes</option>
</select>
</td>
</tr>
And the javascript:
function setOther(data){
var jdata=JSON.parse(data);
document.getElementsByName("date_of_incident_a")[0].value=jdata.doi;
document.getElementsByName("date_of_incident_s")[0].innerHTML=jdata.doi;
document.getElementsByName("transfer_to_lit_a")[0].value=jdata.ttl;
document.getElementsByName("transfer_to_lit_s")[0].innerHTML=jdata.ttl;
document.getElementsByName("filed_suit_a")[0].value=jdata.fsd;
document.getElementsByName("filed_suit_s")[0].innerHTML=jdata.fsd;
document.getElementsByName("phase_assigned_a")[0].value=jdata.pa;
document.getElementsByName("phase_assigned_s")[0].innerHTML=jdata.pa;
alert ("value to set is : " + jdata.ptm);
$("[name='was_PMV_a')").val(jdata.ptm);
document.getElementsByName("was_PMV_s")[0].innerHTML=jdata.ptm;
document.getElementsByName("trial_date_a")[0].value=jdata.td;
document.getElementsByName("trial_date_s")[0].innerHTML=jdata.td;
document.getElementsByName("ALocation_a")[0].value=jdata.al;
document.getElementsByName("settlement_t4")[0].value=Math.round(jdata.sto);
formatValue('4');
I have a feeling that the disconnect is on the recoveryForm.php... does this need to be a dropdown menu? What would be the simplest way to display the returned value of jdata.ptm (yes/no) on the form?
No matter what I do the value on the form shows as "No"... I'm thinking this has to be a simple fix on the form?
EDIT - I believe I have isolated my problem to my getOther.php file, does anybody see any discrepencies?
<?php
$success=FALSE;
$postCasenum = getPostCasenum();
#header('Content-Type: application/json');
$sql = "select cases.date_of_incident, cases.case_date_9, cases.case_date_3, user_tab6_data.Trial_Phase, cases.case_date_5, user_case_data.ALocation, cases.staff_1, cases.staff_8, user_case_data.PMV_to_MVA, ";
$sql=$sql."(select sum(insurance.actual) from insurance where case_num=cases.casenum) as sumTotal ";
$sql=$sql."from cases LEFT JOIN user_tab6_data ON cases.casenum=user_tab6_data.case_id ";
$sql=$sql."LEFT JOIN user_case_data ON cases.casenum=user_case_data.casenum ";
$sql=$sql."WHERE cases.casenum=?";
$conn = odbc_connect( "needles","dba","sql" );
if( $conn ) {
#echo $sql;
$stmt=odbc_prepare($conn, $sql);
$queryResult=odbc_execute($stmt, array($postCasenum));
if (odbc_fetch_row($stmt)) {
$data = [
'doi' => odbc_result($stmt,1),
'ttl' => odbc_result($stmt,2),
'fsd' => odbc_result($stmt,3),
'pa' => odbc_result($stmt,4),
'td' => odbc_result($stmt,5),
'al' => prepString(odbc_result($stmt,6)),
'sl' => odbc_result($stmt,7),
's8' => odbc_result($stmt,8),
'ptm' => empty(odbc_result($stmt,9)) ? "No" : "Yes",
'sto' => odbc_result($stmt,10)
];
echo json_encode($data);
}
// while(odbc_fetch_row($stmt)){
// $json=$json.'"doi":"'.odbc_result($stmt,1).'",';
// $json=$json.'"ttl":"'.odbc_result($stmt,2).'",';
// $json=$json.'"fsd":"'.odbc_result($stmt,3).'",';
// $json=$json.'"pa":"'.odbc_result($stmt,4).'",';
// $json=$json.'"td":"'.odbc_result($stmt,5).'",';
// $json=$json.'"al":"'.prepString(odbc_result($stmt,6)).'",';
// $json=$json.'"s1":"'.odbc_result($stmt,7).'",';
// $json=$json.'"s8":"'.odbc_result($stmt,8).'",';
// $json=$json.'"ptm":"'.odbc_result($stmt,9).'",';
// $json=$json.'"sto":"'.odbc_result($stmt,10).'"';
// }
// $json=$json.'}';
// echo $json;
#echo "you found me!";
odbc_close( $conn );
} else {
echo "{}";
}
?>
<?php
function getPostCasenum(){
return $_POST["casenum"];
}
function prepString($myStr){
$ret=str_replace('"',"",$myStr);
return $ret;
}
?>


document.getElementsByName("was_PMV_s")[0].value = jdata.ptm;$("[name='was_PMV_a')").val...should be$("[name='was_PMV_a']").val