这是Java脚本函数。我希望它使div“结果”可见并显示输出。

但是它没有显示结果,php代码执行没有错误。 为什么这不显示任何输出。

我正在尝试将结果附加到用户提交某些数据的同一页底部

<script>
function myFunction()
{
var e = document.getElementById("resultss");
e.style.display = "block";
<?php

$format =  $_SESSION["ff"];
$ses_id = $_SESSION["id"];
$filena = $_SESSION["filename"];
//$pubquery = $_SESSION["pubquery"];
$result1 = shell_exec("C:\Python27\python.exe C:\Python27\PredictoR\Model_desc.py $format $ses_id $filena  2>&1");
$properties = explode(" ", $result1);
if($properties[0] == 1)
{
$property = "Substrate";
} else  {
$property = "Non-substrate";
}
$molwt = trim(preg_replace('/\s+/', ' ', $properties[1]));
$nhd = trim(preg_replace('/\s+/', ' ', $properties[2]));
$nha = trim(preg_replace('/\s+/', ' ', $properties[3]));
$logp = trim(preg_replace('/\s+/', ' ', $properties[4]));

?>

var molwt = <?php echo json_encode( $molwt); ?>;
var nhd = <?php echo json_encode( $nhd); ?>;
var nha = <?php echo json_encode( $nha); ?>;
var logp = <?php echo json_encode( $logp); ?>;
var property = <?php echo json_encode( $property); ?>;

document.getElementById('properties').innerHTML="Molecule is : "+property+"  \n\
<br/>Molecular weight is : "+molwt+" \n\
<br/>No. of hydrogen bond donors = "+nhd+"\n\
<br/>No. of hydrogen bond acceptors = "+nha+"\n\
<br/>Log P :  = "+logp+";

}

===============>>#1 票数:0

首先,关闭脚本标签</script>第二,我看不到您调用函数myFunction() 尝试调用它。 希望对您有所帮助。

因此,您的代码应类似于:

<script>
  function myFunction()
  {
    var e = document.getElementById("resultss");
    e.style.display = "block";
<?php
$format = $_SESSION["ff"];
$ses_id = $_SESSION["id"];
$filena = $_SESSION["filename"];
//$pubquery = $_SESSION["pubquery"];
$result1 = shell_exec("C:\Python27\python.exe C:\Python27\PredictoR\Model_desc.py $format $ses_id $filena  2>&1");
$properties = explode(" ", $result1);
if ($properties[0] == 1) {
  $property = "Substrate";
} else {
  $property = "Non-substrate";
}
$molwt = trim(preg_replace('/\s+/', ' ', $properties[1]));
$nhd = trim(preg_replace('/\s+/', ' ', $properties[2]));
$nha = trim(preg_replace('/\s+/', ' ', $properties[3]));
$logp = trim(preg_replace('/\s+/', ' ', $properties[4]));
?>

    var molwt = <?php echo json_encode($molwt); ?>;
    var nhd = <?php echo json_encode($nhd); ?>;
    var nha = <?php echo json_encode($nha); ?>;
    var logp = <?php echo json_encode($logp); ?>;
    var property = <?php echo json_encode($property); ?>;

    document.getElementById('properties').innerHTML = "Molecule is : " + property + "  \n\
<br/>Molecular weight is : " + molwt + " \n\
<br/>No. of hydrogen bond donors = " + nhd + "\n\
<br/>No. of hydrogen bond acceptors = " + nha + "\n\
<br/>Log P :  = " + logp;

  }
  myFunction();
</script>

  ask by msk3002 translate from so

未解决问题?本站智能推荐: