简体   繁体   English

隐藏的Div没有使用javascript输出

[英]No output from hidden Div with javascript

This is the java script function.I want it to make the div "resultss" visible and show the output. 这是Java脚本函数。我希望它使div“结果”可见并显示输出。

But it's not displaying results, php code is executed without errors. 但是它没有显示结果,php代码执行没有错误。 Whys is this not displaying any output. 为什么这不显示任何输出。

I'm trying to append the results at the bottom of same page where user submits some data 我正在尝试将结果附加到用户提交某些数据的同一页底部

<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+";

}

First of all close the script tag </script> Secondly I can not see you calling your function myFunction() . 首先,关闭脚本标签</script>第二,我看不到您调用函数myFunction() Try calling it. 尝试调用它。 I hope it helps. 希望对您有所帮助。

So you code should look something like: 因此,您的代码应类似于:

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM